From 063ceb215f858a8e2a5bde85d8f9ca24240894c6 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 21 Sep 2020 15:20:41 +0900 Subject: Separate input component --- src/settings/components/ui/Radio.tsx | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/settings/components/ui/Radio.tsx (limited to 'src/settings/components/ui/Radio.tsx') diff --git a/src/settings/components/ui/Radio.tsx b/src/settings/components/ui/Radio.tsx new file mode 100644 index 0000000..20d4ad6 --- /dev/null +++ b/src/settings/components/ui/Radio.tsx @@ -0,0 +1,44 @@ +import React from "react"; +import "./Input.scss"; + +interface Props extends React.AllHTMLAttributes { + name: string; + error?: string; + label: string; + value: string; + onValueChange?: (name: string, value: string) => void; + onBlur?: (e: React.FocusEvent) => void; +} + +class Input extends React.Component { + renderRadio(props: Props) { + const inputClassName = props.error ? "input-error" : ""; + const pp = { ...props }; + delete pp.onValueChange; + return ( +
+ +
+ ); + } + + render() { + return this.renderRadio(this.props); + } + + bindOnChange(e: React.ChangeEvent) { + if (this.props.onValueChange) { + this.props.onValueChange(e.target.name, e.target.value); + } + } +} + +export default Input; -- cgit v1.2.3 From c28ae6b82860693b8e6b012a939fb8a3dd320e23 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 21 Sep 2020 16:08:44 +0900 Subject: Introduce styled-components on settings ui --- src/settings/components/site.scss | 8 +-- src/settings/components/ui/AddButton.scss | 13 ----- src/settings/components/ui/AddButton.tsx | 31 +++++++----- src/settings/components/ui/DeleteButton.scss | 13 ----- src/settings/components/ui/DeleteButton.tsx | 30 ++++++----- src/settings/components/ui/Input.scss | 29 ----------- src/settings/components/ui/Radio.tsx | 59 +++++++++------------ src/settings/components/ui/Text.tsx | 70 ++++++++++++++----------- src/settings/components/ui/TextArea.tsx | 76 ++++++++++++++++------------ 9 files changed, 145 insertions(+), 184 deletions(-) delete mode 100644 src/settings/components/ui/AddButton.scss delete mode 100644 src/settings/components/ui/DeleteButton.scss delete mode 100644 src/settings/components/ui/Input.scss (limited to 'src/settings/components/ui/Radio.tsx') diff --git a/src/settings/components/site.scss b/src/settings/components/site.scss index c0c4f9e..e8415e8 100644 --- a/src/settings/components/site.scss +++ b/src/settings/components/site.scss @@ -1,12 +1,6 @@ .vimvixen-settings-form { padding: 2px; - - textarea[name=json] { - font-family: monospace; - width: 100%; - min-height: 64ex; - resize: vertical; - } + font-family: system-ui; fieldset { margin: 0; diff --git a/src/settings/components/ui/AddButton.scss b/src/settings/components/ui/AddButton.scss deleted file mode 100644 index beb5688..0000000 --- a/src/settings/components/ui/AddButton.scss +++ /dev/null @@ -1,13 +0,0 @@ -.ui-add-button { - border: none; - padding: 4; - display: inline; - background: none; - font-weight: bold; - color: green; - cursor: pointer; - - &:hover { - color: darkgreen; - } -} diff --git a/src/settings/components/ui/AddButton.tsx b/src/settings/components/ui/AddButton.tsx index c15a732..8cf4300 100644 --- a/src/settings/components/ui/AddButton.tsx +++ b/src/settings/components/ui/AddButton.tsx @@ -1,19 +1,24 @@ -import "./AddButton.scss"; import React from "react"; +import styled from "styled-components"; -type Props = React.AllHTMLAttributes; +const Button = styled.input` + border: none; + padding: 4; + display: inline; + background: none; + font-weight: bold; + color: green; + cursor: pointer; -class AddButton extends React.Component { - render() { - return ( - - ); + &:hover { + color: darkgreen; } -} +`; + +type Props = React.InputHTMLAttributes; + +const AddButton: React.FC = (props) => ( +