-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(web): Add CheckboxField component (#508)
Co-authored-by: 長田淳史 <> Co-authored-by: koji endo <[email protected]> Co-authored-by: KaWaite <[email protected]>
- Loading branch information
1 parent
61c9378
commit 3a12f5f
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import CheckBoxField from "."; | ||
|
||
const meta: Meta<typeof CheckBoxField> = { | ||
component: CheckBoxField, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof CheckBoxField>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
label: "takanawa_3D_Tiles", | ||
checked: false, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import Icon from "@reearth/beta/components/Icon"; | ||
import Text from "@reearth/beta/components/Text"; | ||
import { styled, useTheme } from "@reearth/services/theme"; | ||
|
||
export type Props = { | ||
onClick?: (value: boolean) => void; | ||
checked?: boolean; | ||
label: string; | ||
}; | ||
|
||
const CheckBoxField: React.FC<Props> = ({ onClick, checked, label }) => { | ||
const theme = useTheme(); | ||
return ( | ||
<Field onClick={() => onClick?.(!checked)}> | ||
<BoxField>{checked && <CheckMark icon="checkmark" />}</BoxField> | ||
{label && ( | ||
<Text size="footnote" color={theme.general.content.main}> | ||
{label} | ||
</Text> | ||
)} | ||
</Field> | ||
); | ||
}; | ||
|
||
const Field = styled.button` | ||
display: flex; | ||
align-items: center; | ||
gap: 12px; | ||
width: 100%; | ||
height: 20px; | ||
`; | ||
|
||
const BoxField = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
box-sizing: border-box; | ||
width: 20px; | ||
height: 20px; | ||
border: 1px solid ${({ theme }) => theme.general.content.weak}; | ||
border-radius: 4px; | ||
`; | ||
|
||
const CheckMark = styled(Icon)` | ||
width: 15px; | ||
height: 10.83px; | ||
color: ${({ theme }) => theme.general.content.main}; | ||
`; | ||
|
||
export default CheckBoxField; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters