From fe1a2eac338a8eb7913e18d1bf2367ef165c73fb Mon Sep 17 00:00:00 2001 From: zeppi Date: Thu, 3 Feb 2022 21:56:44 -0500 Subject: [PATCH] use radio buttons for comment server selection --- ui/component/common/input-radio-panel.jsx | 39 -------------- .../input-radio-panel-addCommentServer.jsx | 8 +-- ui/component/settingCommentsServer/view.jsx | 43 +++++++++------ ui/scss/all.scss | 2 +- ui/scss/component/_form-field.scss | 15 ++++++ ui/scss/component/_input-radio-panel.scss | 52 ------------------- ui/scss/component/_settings.scss | 20 +++++++ 7 files changed, 67 insertions(+), 112 deletions(-) delete mode 100644 ui/component/common/input-radio-panel.jsx delete mode 100644 ui/scss/component/_input-radio-panel.scss create mode 100644 ui/scss/component/_settings.scss diff --git a/ui/component/common/input-radio-panel.jsx b/ui/component/common/input-radio-panel.jsx deleted file mode 100644 index a64d0a084..000000000 --- a/ui/component/common/input-radio-panel.jsx +++ /dev/null @@ -1,39 +0,0 @@ -// @flow -import React from 'react'; -import * as ICONS from 'constants/icons'; -import Button from 'component/button'; -import classnames from 'classnames'; - -type Props = { - onClick: (CommentServerDetails) => void, - onRemove?: (CommentServerDetails) => void, - active: boolean, - serverDetails: CommentServerDetails, -}; - -const InputTogglePanel = (props: Props) => { - const { onClick, active, serverDetails, onRemove } = props; - - return ( -
onClick(serverDetails)} - className={classnames('input-toggle-panel', { 'input-toggle-panel--active': active })} - > -
-
{`${serverDetails.name}`}
-
{`${serverDetails.url}`}
-
- {onRemove && ( -
); diff --git a/ui/component/settingCommentsServer/view.jsx b/ui/component/settingCommentsServer/view.jsx index 7ded7fee1..d17804d16 100644 --- a/ui/component/settingCommentsServer/view.jsx +++ b/ui/component/settingCommentsServer/view.jsx @@ -1,10 +1,10 @@ // @flow -import { COMMENT_SERVER_API } from 'config'; // COMMENT_SERVER_NAME, +import { COMMENT_SERVER_API, COMMENT_SERVER_NAME } from 'config'; import React from 'react'; import Comments from 'comments'; -import InputTogglePanel from 'component/common/input-radio-panel'; import ItemInputRow from './internal/input-radio-panel-addCommentServer'; import Button from 'component/button'; +import { FormField } from 'component/common/form-components/form-field'; type Props = { customServerEnabled: boolean, @@ -14,7 +14,7 @@ type Props = { setCustomServers: (Array) => void, customCommentServers: Array, }; -const defaultServer = { name: 'Default', url: COMMENT_SERVER_API }; +const defaultServer = { name: COMMENT_SERVER_NAME, url: COMMENT_SERVER_API }; function SettingCommentsServer(props: Props) { const { customServerEnabled, @@ -53,7 +53,7 @@ function SettingCommentsServer(props: Props) { setAddServer(false); }; - const handleRemoveServer = (serverItem) => { + const handleRemoveServer = (serverItem: CommentServerDetails) => { handleSelectServer(defaultServer); const newCustomServers = customCommentServers.slice().filter((server) => { return server.url !== serverItem.url; @@ -61,25 +61,36 @@ function SettingCommentsServer(props: Props) { setCustomServers(newCustomServers); }; + const commentServerLabel = (serverDetails, onRemove) => ( + + {serverDetails.name} + {serverDetails.url} + {onRemove &&