-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
piersss
authored
Feb 16, 2024
1 parent
8b69f3d
commit 68a2ba4
Showing
62 changed files
with
1,200 additions
and
208 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
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
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,44 @@ | ||
@import "src/styles"; | ||
|
||
$component: checkbox; | ||
|
||
.checkbox { | ||
display: flex; | ||
position: relative; | ||
|
||
&__input { | ||
position: absolute; | ||
opacity: 0; | ||
} | ||
|
||
&__input:checked { | ||
|
||
& + .#{$component}__box { | ||
background-color: var(--c-primary); | ||
} | ||
|
||
& + .#{$component}__box .#{$component}__icon { | ||
display: block; | ||
} | ||
} | ||
|
||
&__box { | ||
@extend %flex-align-center; | ||
|
||
position: relative; | ||
width: 1.5rem; | ||
height: 1.5rem; | ||
border-radius: .25rem; | ||
background-color: var(--c-black); | ||
} | ||
|
||
&__icon { | ||
display: none; | ||
width: .875rem; | ||
} | ||
|
||
&__label { | ||
margin-inline-start: 1rem; | ||
font-weight: var(--fw-500); | ||
} | ||
} |
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,59 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import classNames from 'classnames'; | ||
|
||
import Icon from '../Icon/Icon'; | ||
|
||
import './Checkbox.scss'; | ||
|
||
export type HTMLInputProps = JSX.IntrinsicElements['input']; | ||
|
||
export interface CheckboxProps extends Omit<HTMLInputProps, 'onChange'> { | ||
label: string; | ||
value: string; | ||
onChange: (value: string) => void; | ||
checkClassName?: string; | ||
className?: string; | ||
labelClassName?: string; | ||
} | ||
|
||
const Checkbox: FC<CheckboxProps> = ({ | ||
checked, | ||
disabled, | ||
label, | ||
value, | ||
onChange, | ||
checkClassName = '', | ||
className = '', | ||
labelClassName = '', | ||
...checkboxProps | ||
}) => { | ||
const handleChange = (): void => { | ||
onChange(value); | ||
}; | ||
|
||
const checkboxClassNames = classNames('checkbox', { | ||
'checkbox--is-disabled': disabled, | ||
}, className); | ||
|
||
return ( | ||
<label id={label} className={checkboxClassNames}> | ||
<input | ||
{...checkboxProps} | ||
type="checkbox" | ||
checked={checked} | ||
disabled={disabled} | ||
onChange={handleChange} | ||
className="checkbox__input" | ||
/> | ||
|
||
<div className={`checkbox__box ${checkClassName}`}> | ||
<Icon name="check" className="checkbox__icon" /> | ||
</div> | ||
|
||
<span className={`checkbox__label ${labelClassName}`}>{label}</span> | ||
</label> | ||
); | ||
}; | ||
|
||
export default Checkbox; |
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
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,38 @@ | ||
@import 'src/styles'; | ||
|
||
$component: checkbox-group; | ||
|
||
.#{$component} { | ||
border-radius: .25rem; | ||
background: var(--c-dark); | ||
|
||
&[open] { | ||
|
||
.#{$component}__summary-icon { | ||
transform: rotate(180deg); | ||
} | ||
} | ||
|
||
&__summary { | ||
display: flex; | ||
justify-content: space-between; | ||
padding: 1rem; | ||
cursor: pointer; | ||
} | ||
|
||
&__summary-icon { | ||
min-width: 1.5rem; | ||
min-height: 1.5rem; | ||
color: var(--c-text-grey); | ||
} | ||
|
||
&__list { | ||
margin-block-start: .25rem; | ||
padding: 1rem; | ||
padding-block-start: 0; | ||
} | ||
|
||
&__list-item + &__list-item { | ||
margin-block-start: .5rem; | ||
} | ||
} |
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,42 @@ | ||
import { FC, ReactElement } from 'react'; | ||
|
||
import Checkbox, { CheckboxProps } from '../../components/Checkbox/Checkbox'; | ||
import Icon from '../../components/Icon/Icon'; | ||
|
||
import './CheckboxGroup.scss'; | ||
|
||
interface CheckboxGroupCheckbox extends CheckboxProps { | ||
key: string; | ||
} | ||
|
||
interface CheckboxGroupProps { | ||
checkboxes: CheckboxGroupCheckbox[], | ||
label: string; | ||
className?: string; | ||
} | ||
|
||
const CheckboxGroup: FC<CheckboxGroupProps> = ({ checkboxes, label, className = '' }): ReactElement => ( | ||
<details className={`checkbox-group ${className}`}> | ||
<summary className="checkbox-group__summary"> | ||
{label} | ||
|
||
<Icon | ||
name="chevron-down" | ||
className="checkbox-group__summary-icon" | ||
/> | ||
</summary> | ||
|
||
<ul className="checkbox-group__list"> | ||
{checkboxes.map(checkbox => ( | ||
<li | ||
key={checkbox.key} | ||
className="checkbox-group__list-item" | ||
> | ||
<Checkbox {...checkbox} /> | ||
</li> | ||
))} | ||
</ul> | ||
</details> | ||
); | ||
|
||
export default CheckboxGroup; |
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 |
---|---|---|
@@ -1,32 +1,93 @@ | ||
@import "src/styles"; | ||
|
||
.dialog { | ||
margin: 1rem auto; | ||
top: var(--top-bar-height); | ||
margin: 0; | ||
width: 100%; | ||
min-width: 100%; | ||
height: 100vh; | ||
height: 100svh; | ||
padding: 0; | ||
max-width: 40rem; | ||
overflow: hidden; | ||
height: calc(100dvh - var(--top-bar-height)); | ||
padding: var(--page-padding); | ||
overflow-y: auto; | ||
overflow-x: hidden; | ||
background: var(--c-black); | ||
|
||
&::backdrop { | ||
background-color: rgba(0, 0, 0, .5); | ||
opacity: 0; | ||
cursor: pointer; | ||
} | ||
|
||
&__content { | ||
display: flex; | ||
position: relative; | ||
padding-top: 2rem; | ||
&[open] { | ||
animation: slideIn .3s ease-out normal; | ||
} | ||
|
||
&--is-closing { | ||
animation: slideOut .3s ease-in normal !important; | ||
} | ||
|
||
@include for-size(tablet-portrait-up) { | ||
top: 0; | ||
margin: auto; | ||
padding: 0; | ||
padding-block: 2rem; | ||
max-width: 40rem; | ||
min-width: unset; | ||
max-height: 100%; | ||
min-height: 100%; | ||
height: auto; | ||
background: none; | ||
overflow: hidden; | ||
background: var(--c-dark); | ||
|
||
&[open] { | ||
animation: fadeIn .2s ease-out normal; | ||
} | ||
|
||
&--is-closing { | ||
animation: fadeOut .2s ease-in normal !important; | ||
} | ||
|
||
&::backdrop { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
&__header { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-block-end: 1.5rem; | ||
width: 100%; | ||
} | ||
|
||
&__label { | ||
font-size: 1.125rem; | ||
font-weight: var(--fw-700); | ||
} | ||
|
||
&__close-button { | ||
position: absolute; | ||
top: 1rem; | ||
right: 1rem; | ||
justify-content: flex-end; | ||
margin-inline-start: auto; | ||
width: 1.5rem; | ||
color: var(--c-white); | ||
} | ||
|
||
&__content { | ||
display: flex; | ||
flex-direction: column; | ||
position: relative; | ||
overflow: hidden; | ||
|
||
@include for-size(tablet-portrait-up) { | ||
border-radius: .25rem; | ||
height: 100%; | ||
padding: var(--page-padding); | ||
background: var(--c-dark); | ||
} | ||
} | ||
|
||
&__children-wrapper { | ||
|
||
@include for-size(tablet-portrait-up) { | ||
height: calc(100% - 3rem); | ||
} | ||
} | ||
} |
Oops, something went wrong.