-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Showing
23 changed files
with
1,301 additions
and
5 deletions.
There are no files selected for viewing
150 changes: 150 additions & 0 deletions
150
docs/data/base/components/checkbox/UnstyledCheckboxIntroduction/css/index.js
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,150 @@ | ||
import * as React from 'react'; | ||
import { Checkbox } from '@mui/base/Checkbox'; | ||
import { useTheme } from '@mui/system'; | ||
import Check from '@mui/icons-material/Check'; | ||
|
||
export default function UnstyledCheckboxIntroduction() { | ||
return ( | ||
<div style={{ display: 'flex', gap: 15 }}> | ||
<Checkbox | ||
className="Checkbox" | ||
aria-label="Basic checkbox, on by default" | ||
defaultChecked | ||
> | ||
<Checkbox.Indicator className="Checkbox-indicator"> | ||
<Check className="Checkbox-icon" /> | ||
</Checkbox.Indicator> | ||
</Checkbox> | ||
<Checkbox className="Checkbox" aria-label="Basic checkbox, off by default"> | ||
<Checkbox.Indicator className="Checkbox-indicator"> | ||
<Check className="Checkbox-icon" /> | ||
</Checkbox.Indicator> | ||
</Checkbox> | ||
<Checkbox | ||
className="Checkbox" | ||
aria-label="Disabled checkbox, on by default" | ||
defaultChecked | ||
disabled | ||
> | ||
<Checkbox.Indicator className="Checkbox-indicator"> | ||
<Check className="Checkbox-icon" /> | ||
</Checkbox.Indicator> | ||
</Checkbox> | ||
<Checkbox | ||
className="Checkbox" | ||
aria-label="Disabled checkbox, off by default" | ||
disabled | ||
> | ||
<Checkbox.Indicator className="Checkbox-indicator"> | ||
<Check className="Checkbox-icon" /> | ||
</Checkbox.Indicator> | ||
</Checkbox> | ||
<Styles /> | ||
</div> | ||
); | ||
} | ||
|
||
const grey = { | ||
50: '#F3F6F9', | ||
100: '#E5EAF2', | ||
200: '#DAE2ED', | ||
300: '#C7D0DD', | ||
400: '#B0B8C4', | ||
500: '#9DA8B7', | ||
600: '#6B7A90', | ||
700: '#434D5B', | ||
800: '#303740', | ||
900: '#1C2025', | ||
}; | ||
|
||
function useIsDarkMode() { | ||
const theme = useTheme(); | ||
return theme.palette.mode === 'dark'; | ||
} | ||
|
||
function Styles() { | ||
// Replace this with your app logic for determining dark modes | ||
const isDarkMode = useIsDarkMode(); | ||
|
||
return ( | ||
<style> | ||
{` | ||
.Checkbox { | ||
all: unset; | ||
box-sizing: border-box; | ||
text-align: center; | ||
width: 32px; | ||
height: 32px; | ||
padding: 0; | ||
border-radius: 4px; | ||
border: 2px solid ${grey[600]}; | ||
background: none; | ||
transition-property: background, border-color; | ||
transition-duration: 0.15s; | ||
} | ||
.Checkbox[data-disabled] { | ||
opacity: 0.4; | ||
cursor: not-allowed; | ||
} | ||
.Checkbox:hover:not([data-disabled]) { | ||
border-color: ${isDarkMode ? grey[600] : grey[700]}; | ||
} | ||
.Checkbox:focus-visible { | ||
outline: 2px solid ${isDarkMode ? grey[600] : grey[500]}; | ||
outline-offset: 2px; | ||
} | ||
.Checkbox[data-state="checked"] { | ||
border-color: ${grey[800]}; | ||
background: ${grey[800]}; | ||
} | ||
.Checkbox[data-state="checked"]:not([data-disabled]):hover { | ||
background: ${grey[900]}; | ||
border-color: transparent; | ||
} | ||
.Checkbox-indicator { | ||
height: 100%; | ||
display: inline-block; | ||
visibility: hidden; | ||
color: ${isDarkMode ? grey[900] : grey[100]}; | ||
} | ||
.Checkbox-indicator[data-state="checked"] { | ||
visibility: visible; | ||
} | ||
.Checkbox-icon { | ||
height: 100%; | ||
} | ||
@media (prefers-color-scheme: dark) { | ||
.Checkbox { | ||
border-color: ${grey[500]}; | ||
} | ||
.Checkbox[data-state="checked"] { | ||
border-color: ${grey[300]}; | ||
background: ${grey[300]}; | ||
} | ||
.Checkbox:hover:not([data-disabled]) { | ||
border-color: ${grey[100]}; | ||
} | ||
.Checkbox[data-state="checked"]:not([data-disabled]):hover { | ||
background: ${grey[100]}; | ||
border-color: transparent; | ||
} | ||
.Checkbox-indicator { | ||
color: ${grey[900]}; | ||
} | ||
} | ||
`} | ||
</style> | ||
); | ||
} |
150 changes: 150 additions & 0 deletions
150
docs/data/base/components/checkbox/UnstyledCheckboxIntroduction/css/index.tsx
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,150 @@ | ||
import * as React from 'react'; | ||
import { Checkbox } from '@mui/base/Checkbox'; | ||
import { useTheme } from '@mui/system'; | ||
import Check from '@mui/icons-material/Check'; | ||
|
||
export default function UnstyledCheckboxIntroduction() { | ||
return ( | ||
<div style={{ display: 'flex', gap: 15 }}> | ||
<Checkbox | ||
className="Checkbox" | ||
aria-label="Basic checkbox, on by default" | ||
defaultChecked | ||
> | ||
<Checkbox.Indicator className="Checkbox-indicator"> | ||
<Check className="Checkbox-icon" /> | ||
</Checkbox.Indicator> | ||
</Checkbox> | ||
<Checkbox className="Checkbox" aria-label="Basic checkbox, off by default"> | ||
<Checkbox.Indicator className="Checkbox-indicator"> | ||
<Check className="Checkbox-icon" /> | ||
</Checkbox.Indicator> | ||
</Checkbox> | ||
<Checkbox | ||
className="Checkbox" | ||
aria-label="Disabled checkbox, on by default" | ||
defaultChecked | ||
disabled | ||
> | ||
<Checkbox.Indicator className="Checkbox-indicator"> | ||
<Check className="Checkbox-icon" /> | ||
</Checkbox.Indicator> | ||
</Checkbox> | ||
<Checkbox | ||
className="Checkbox" | ||
aria-label="Disabled checkbox, off by default" | ||
disabled | ||
> | ||
<Checkbox.Indicator className="Checkbox-indicator"> | ||
<Check className="Checkbox-icon" /> | ||
</Checkbox.Indicator> | ||
</Checkbox> | ||
<Styles /> | ||
</div> | ||
); | ||
} | ||
|
||
const grey = { | ||
50: '#F3F6F9', | ||
100: '#E5EAF2', | ||
200: '#DAE2ED', | ||
300: '#C7D0DD', | ||
400: '#B0B8C4', | ||
500: '#9DA8B7', | ||
600: '#6B7A90', | ||
700: '#434D5B', | ||
800: '#303740', | ||
900: '#1C2025', | ||
}; | ||
|
||
function useIsDarkMode() { | ||
const theme = useTheme(); | ||
return theme.palette.mode === 'dark'; | ||
} | ||
|
||
function Styles() { | ||
// Replace this with your app logic for determining dark modes | ||
const isDarkMode = useIsDarkMode(); | ||
|
||
return ( | ||
<style> | ||
{` | ||
.Checkbox { | ||
all: unset; | ||
box-sizing: border-box; | ||
text-align: center; | ||
width: 32px; | ||
height: 32px; | ||
padding: 0; | ||
border-radius: 4px; | ||
border: 2px solid ${grey[600]}; | ||
background: none; | ||
transition-property: background, border-color; | ||
transition-duration: 0.15s; | ||
} | ||
.Checkbox[data-disabled] { | ||
opacity: 0.4; | ||
cursor: not-allowed; | ||
} | ||
.Checkbox:hover:not([data-disabled]) { | ||
border-color: ${isDarkMode ? grey[600] : grey[700]}; | ||
} | ||
.Checkbox:focus-visible { | ||
outline: 2px solid ${isDarkMode ? grey[600] : grey[500]}; | ||
outline-offset: 2px; | ||
} | ||
.Checkbox[data-state="checked"] { | ||
border-color: ${grey[800]}; | ||
background: ${grey[800]}; | ||
} | ||
.Checkbox[data-state="checked"]:not([data-disabled]):hover { | ||
background: ${grey[900]}; | ||
border-color: transparent; | ||
} | ||
.Checkbox-indicator { | ||
height: 100%; | ||
display: inline-block; | ||
visibility: hidden; | ||
color: ${isDarkMode ? grey[900] : grey[100]}; | ||
} | ||
.Checkbox-indicator[data-state="checked"] { | ||
visibility: visible; | ||
} | ||
.Checkbox-icon { | ||
height: 100%; | ||
} | ||
@media (prefers-color-scheme: dark) { | ||
.Checkbox { | ||
border-color: ${grey[500]}; | ||
} | ||
.Checkbox[data-state="checked"] { | ||
border-color: ${grey[300]}; | ||
background: ${grey[300]}; | ||
} | ||
.Checkbox:hover:not([data-disabled]) { | ||
border-color: ${grey[100]}; | ||
} | ||
.Checkbox[data-state="checked"]:not([data-disabled]):hover { | ||
background: ${grey[100]}; | ||
border-color: transparent; | ||
} | ||
.Checkbox-indicator { | ||
color: ${grey[900]}; | ||
} | ||
} | ||
`} | ||
</style> | ||
); | ||
} |
Oops, something went wrong.