diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-09-21 21:09:01 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-09-21 22:07:55 +0900 |
commit | 6a674fbc53c265e27b87f86e4db032433733f2f8 (patch) | |
tree | 787920ab180576bfa210c6ccec2d6f7bae3c14e3 /src/settings/components/form/BlacklistForm.tsx | |
parent | c28ae6b82860693b8e6b012a939fb8a3dd320e23 (diff) |
Introduce styled-components on form fields
Diffstat (limited to 'src/settings/components/form/BlacklistForm.tsx')
-rw-r--r-- | src/settings/components/form/BlacklistForm.tsx | 80 |
1 files changed, 53 insertions, 27 deletions
diff --git a/src/settings/components/form/BlacklistForm.tsx b/src/settings/components/form/BlacklistForm.tsx index 859cb9f..4d794f4 100644 --- a/src/settings/components/form/BlacklistForm.tsx +++ b/src/settings/components/form/BlacklistForm.tsx @@ -1,9 +1,29 @@ -import "./BlacklistForm.scss"; +import styled from "styled-components"; import AddButton from "../ui/AddButton"; import DeleteButton from "../ui/DeleteButton"; import React from "react"; import Blacklist, { BlacklistItem } from "../../../shared/settings/Blacklist"; +const Grid = styled.div``; + +const GridRow = styled.div` + display: flex; +`; + +const GridCell = styled.div<{ grow?: number }>` + &:nth-child(1) { + flex-grow: 1; + } + &:nth-child(2) { + flex-shrink: 1; + } +`; + +const Input = styled.input` + width: 100%; + box-sizing: border-box; +`; + interface Props { value: Blacklist; onChange: (value: Blacklist) => void; @@ -19,37 +39,43 @@ class BlacklistForm extends React.Component<Props> { render() { return ( - <div className="form-blacklist-form"> - {this.props.value.items.map((item, index) => { - if (item.partial) { - return null; - } - return ( - <div key={index} className="form-blacklist-form-row"> - <input - data-index={index} - type="text" - name="url" - className="column-url" - value={item.pattern} - onChange={this.bindValue.bind(this)} - onBlur={this.props.onBlur} - /> - <DeleteButton - data-index={index} - name="delete" - onClick={this.bindValue.bind(this)} - onBlur={this.props.onBlur} - /> - </div> - ); - })} + <> + <Grid> + {this.props.value.items.map((item, index) => { + if (item.partial) { + return null; + } + return ( + <GridRow key={index}> + <GridCell> + <Input + data-index={index} + type="text" + name="url" + value={item.pattern} + placeholder="example.com/mail/*" + onChange={this.bindValue.bind(this)} + onBlur={this.props.onBlur} + /> + </GridCell> + <GridCell> + <DeleteButton + data-index={index} + name="delete" + onClick={this.bindValue.bind(this)} + onBlur={this.props.onBlur} + /> + </GridCell> + </GridRow> + ); + })} + </Grid> <AddButton name="add" style={{ float: "right" }} onClick={this.bindValue.bind(this)} /> - </div> + </> ); } |