-
-
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.
Bifurcate tests Docs stylelint Attempt test fix Ignore perf test in JSDOM Use skip Docs Format Update docs Relocate ScrubArea logic Memo return value Unit tests for parsing and formatting Skip test in browser Tests Relocate pointerDownEvent Remove floating point errors Docs Update allowed chars Bug fixes and feedback Remove autoFocus destructure Remove clamp requirement logic Allow currency symbols Move context menu handler Avoid calling handlers while disabled Unsubscribe from visualViewport Add description to useNumberField Docs Use mergeReactProps Use altKey for smallStep Fix cursor rendering
- Loading branch information
Showing
124 changed files
with
6,743 additions
and
5,778 deletions.
There are no files selected for viewing
186 changes: 186 additions & 0 deletions
186
docs/data/base/components/number-field/UnstyledNumberFieldFormat.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,186 @@ | ||
import * as React from 'react'; | ||
import { NumberField as BaseNumberField } from '@mui/base/NumberField'; | ||
import { styled, css } from '@mui/system'; | ||
|
||
export default function UnstyledNumberFieldFormat() { | ||
const id = React.useId(); | ||
return ( | ||
<NumberField | ||
id={id} | ||
format={{ style: 'currency', currency: 'USD' }} | ||
defaultValue={10} | ||
min={0} | ||
> | ||
<NumberLabel htmlFor={id}>Cost</NumberLabel> | ||
<NumberFieldGroup style={{ display: 'flex', gap: 4 }}> | ||
<NumberFieldDecrement>−</NumberFieldDecrement> | ||
<NumberFieldInput /> | ||
<NumberFieldIncrement>+</NumberFieldIncrement> | ||
</NumberFieldGroup> | ||
</NumberField> | ||
); | ||
} | ||
|
||
const blue = { | ||
100: '#CCE5FF', | ||
200: '#99CCFF', | ||
300: '#66B3FF', | ||
400: '#3399FF', | ||
600: '#0072E6', | ||
800: '#004C99', | ||
}; | ||
|
||
const grey = { | ||
50: '#F9FAFB', | ||
100: '#E5EAF2', | ||
200: '#DAE2ED', | ||
300: '#C7D0DD', | ||
400: '#B0B8C4', | ||
500: '#9DA8B7', | ||
600: '#6B7A90', | ||
700: '#434D5B', | ||
800: '#303740', | ||
900: '#1C2025', | ||
}; | ||
|
||
const NumberLabel = styled('label')` | ||
font-family: 'IBM Plex Sans', sans-serif; | ||
font-size: 1rem; | ||
font-weight: bold; | ||
`; | ||
|
||
const NumberField = styled(BaseNumberField)` | ||
font-family: 'IBM Plex Sans', sans-serif; | ||
font-size: 1rem; | ||
`; | ||
|
||
const NumberFieldGroup = styled(BaseNumberField.Group)` | ||
display: flex; | ||
align-items: center; | ||
margin-top: 0.25rem; | ||
border-radius: 0.25rem; | ||
border: 1px solid ${grey[300]}; | ||
border-color: ${grey[300]}; | ||
overflow: hidden; | ||
&:focus-within { | ||
outline: 2px solid ${blue[100]}; | ||
border-color: ${blue[400]}; | ||
} | ||
.dark & { | ||
border: 1px solid ${grey[700]}; | ||
border-color: ${grey[700]}; | ||
&:focus-within { | ||
outline: 2px solid ${blue[800]}; | ||
border-color: ${blue[400]}; | ||
} | ||
} | ||
`; | ||
|
||
const NumberFieldInput = styled(BaseNumberField.Input)` | ||
position: relative; | ||
z-index: 10; | ||
align-self: stretch; | ||
padding: 0.25rem 0.5rem; | ||
line-height: 1.5; | ||
border: none; | ||
background-color: #fff; | ||
color: ${grey[800]}; | ||
box-shadow: 0 1px 2px 0 rgba(0 0 0 / 0.05); | ||
overflow: hidden; | ||
max-width: 150px; | ||
font-family: inherit; | ||
font-size: inherit; | ||
&:focus { | ||
outline: none; | ||
z-index: 10; | ||
} | ||
.dark & { | ||
background-color: ${grey[900]}; | ||
border-color: ${grey[700]}; | ||
color: ${grey[300]}; | ||
&:focus { | ||
border-color: ${blue[600]}; | ||
} | ||
} | ||
`; | ||
|
||
const buttonStyles = css` | ||
position: relative; | ||
border: none; | ||
font-weight: bold; | ||
transition-property: background-color, border-color, color; | ||
transition-duration: 100ms; | ||
padding: 0.5rem 0.75rem; | ||
flex: 1; | ||
align-self: stretch; | ||
background-color: ${grey[50]}; | ||
color: ${grey[700]}; | ||
margin: 0; | ||
font-family: math, sans-serif; | ||
&[disabled] { | ||
opacity: 0.4; | ||
cursor: not-allowed; | ||
} | ||
.dark & { | ||
background-color: ${grey[800]}; | ||
color: ${grey[300]}; | ||
border-color: ${grey[700]}; | ||
&[disabled] { | ||
opacity: 0.4; | ||
cursor: not-allowed; | ||
} | ||
} | ||
&:hover:not([disabled]) { | ||
background-color: ${grey[100]}; | ||
border-color: ${grey[200]}; | ||
color: ${grey[800]}; | ||
} | ||
&:active:not([disabled]) { | ||
background-color: ${grey[200]}; | ||
} | ||
.dark { | ||
&:hover:not([disabled]) { | ||
background-color: ${grey[800]}; | ||
border-color: ${grey[700]}; | ||
color: ${grey[200]}; | ||
} | ||
&:active:not([disabled]) { | ||
background-color: ${grey[700]}; | ||
} | ||
} | ||
`; | ||
|
||
const NumberFieldDecrement = styled(BaseNumberField.Decrement)` | ||
${buttonStyles} | ||
border-right: 1px solid ${grey[200]}; | ||
border-top-right-radius: 0; | ||
border-bottom-right-radius: 0; | ||
.dark & { | ||
border-right-color: ${grey[700]}; | ||
} | ||
`; | ||
|
||
const NumberFieldIncrement = styled(BaseNumberField.Increment)` | ||
${buttonStyles} | ||
border-top-left-radius: 0; | ||
border-bottom-left-radius: 0; | ||
border-left: 1px solid ${grey[200]}; | ||
.dark & { | ||
border-left-color: ${grey[700]}; | ||
} | ||
`; |
186 changes: 186 additions & 0 deletions
186
docs/data/base/components/number-field/UnstyledNumberFieldFormat.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,186 @@ | ||
import * as React from 'react'; | ||
import { NumberField as BaseNumberField } from '@mui/base/NumberField'; | ||
import { styled, css } from '@mui/system'; | ||
|
||
export default function UnstyledNumberFieldFormat() { | ||
const id = React.useId(); | ||
return ( | ||
<NumberField | ||
id={id} | ||
format={{ style: 'currency', currency: 'USD' }} | ||
defaultValue={10} | ||
min={0} | ||
> | ||
<NumberLabel htmlFor={id}>Cost</NumberLabel> | ||
<NumberFieldGroup style={{ display: 'flex', gap: 4 }}> | ||
<NumberFieldDecrement>−</NumberFieldDecrement> | ||
<NumberFieldInput /> | ||
<NumberFieldIncrement>+</NumberFieldIncrement> | ||
</NumberFieldGroup> | ||
</NumberField> | ||
); | ||
} | ||
|
||
const blue = { | ||
100: '#CCE5FF', | ||
200: '#99CCFF', | ||
300: '#66B3FF', | ||
400: '#3399FF', | ||
600: '#0072E6', | ||
800: '#004C99', | ||
}; | ||
|
||
const grey = { | ||
50: '#F9FAFB', | ||
100: '#E5EAF2', | ||
200: '#DAE2ED', | ||
300: '#C7D0DD', | ||
400: '#B0B8C4', | ||
500: '#9DA8B7', | ||
600: '#6B7A90', | ||
700: '#434D5B', | ||
800: '#303740', | ||
900: '#1C2025', | ||
}; | ||
|
||
const NumberLabel = styled('label')` | ||
font-family: 'IBM Plex Sans', sans-serif; | ||
font-size: 1rem; | ||
font-weight: bold; | ||
`; | ||
|
||
const NumberField = styled(BaseNumberField)` | ||
font-family: 'IBM Plex Sans', sans-serif; | ||
font-size: 1rem; | ||
`; | ||
|
||
const NumberFieldGroup = styled(BaseNumberField.Group)` | ||
display: flex; | ||
align-items: center; | ||
margin-top: 0.25rem; | ||
border-radius: 0.25rem; | ||
border: 1px solid ${grey[300]}; | ||
border-color: ${grey[300]}; | ||
overflow: hidden; | ||
&:focus-within { | ||
outline: 2px solid ${blue[100]}; | ||
border-color: ${blue[400]}; | ||
} | ||
.dark & { | ||
border: 1px solid ${grey[700]}; | ||
border-color: ${grey[700]}; | ||
&:focus-within { | ||
outline: 2px solid ${blue[800]}; | ||
border-color: ${blue[400]}; | ||
} | ||
} | ||
`; | ||
|
||
const NumberFieldInput = styled(BaseNumberField.Input)` | ||
position: relative; | ||
z-index: 10; | ||
align-self: stretch; | ||
padding: 0.25rem 0.5rem; | ||
line-height: 1.5; | ||
border: none; | ||
background-color: #fff; | ||
color: ${grey[800]}; | ||
box-shadow: 0 1px 2px 0 rgba(0 0 0 / 0.05); | ||
overflow: hidden; | ||
max-width: 150px; | ||
font-family: inherit; | ||
font-size: inherit; | ||
&:focus { | ||
outline: none; | ||
z-index: 10; | ||
} | ||
.dark & { | ||
background-color: ${grey[900]}; | ||
border-color: ${grey[700]}; | ||
color: ${grey[300]}; | ||
&:focus { | ||
border-color: ${blue[600]}; | ||
} | ||
} | ||
`; | ||
|
||
const buttonStyles = css` | ||
position: relative; | ||
border: none; | ||
font-weight: bold; | ||
transition-property: background-color, border-color, color; | ||
transition-duration: 100ms; | ||
padding: 0.5rem 0.75rem; | ||
flex: 1; | ||
align-self: stretch; | ||
background-color: ${grey[50]}; | ||
color: ${grey[700]}; | ||
margin: 0; | ||
font-family: math, sans-serif; | ||
&[disabled] { | ||
opacity: 0.4; | ||
cursor: not-allowed; | ||
} | ||
.dark & { | ||
background-color: ${grey[800]}; | ||
color: ${grey[300]}; | ||
border-color: ${grey[700]}; | ||
&[disabled] { | ||
opacity: 0.4; | ||
cursor: not-allowed; | ||
} | ||
} | ||
&:hover:not([disabled]) { | ||
background-color: ${grey[100]}; | ||
border-color: ${grey[200]}; | ||
color: ${grey[800]}; | ||
} | ||
&:active:not([disabled]) { | ||
background-color: ${grey[200]}; | ||
} | ||
.dark { | ||
&:hover:not([disabled]) { | ||
background-color: ${grey[800]}; | ||
border-color: ${grey[700]}; | ||
color: ${grey[200]}; | ||
} | ||
&:active:not([disabled]) { | ||
background-color: ${grey[700]}; | ||
} | ||
} | ||
`; | ||
|
||
const NumberFieldDecrement = styled(BaseNumberField.Decrement)` | ||
${buttonStyles} | ||
border-right: 1px solid ${grey[200]}; | ||
border-top-right-radius: 0; | ||
border-bottom-right-radius: 0; | ||
.dark & { | ||
border-right-color: ${grey[700]}; | ||
} | ||
`; | ||
|
||
const NumberFieldIncrement = styled(BaseNumberField.Increment)` | ||
${buttonStyles} | ||
border-top-left-radius: 0; | ||
border-bottom-left-radius: 0; | ||
border-left: 1px solid ${grey[200]}; | ||
.dark & { | ||
border-left-color: ${grey[700]}; | ||
} | ||
`; |
13 changes: 13 additions & 0 deletions
13
docs/data/base/components/number-field/UnstyledNumberFieldFormat.tsx.preview
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,13 @@ | ||
<NumberField | ||
id={id} | ||
format={{ style: 'currency', currency: 'USD' }} | ||
defaultValue={10} | ||
min={0} | ||
> | ||
<NumberLabel htmlFor={id}>Cost</NumberLabel> | ||
<NumberFieldGroup style={{ display: 'flex', gap: 4 }}> | ||
<NumberFieldDecrement>−</NumberFieldDecrement> | ||
<NumberFieldInput /> | ||
<NumberFieldIncrement>+</NumberFieldIncrement> | ||
</NumberFieldGroup> | ||
</NumberField> |
Oops, something went wrong.