-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into split-test-package
- Loading branch information
Showing
142 changed files
with
4,153 additions
and
1,415 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
185 changes: 185 additions & 0 deletions
185
docs/data/base/components/number-input/NumberInputAdornments.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,185 @@ | ||
import * as React from 'react'; | ||
import { | ||
Unstable_NumberInput as NumberInput, | ||
numberInputClasses, | ||
} from '@mui/base/Unstable_NumberInput'; | ||
import Box from '@mui/material/Box'; | ||
import { styled } from '@mui/system'; | ||
|
||
const CustomNumberInput = React.forwardRef(function CustomNumberInput(props, ref) { | ||
return ( | ||
<NumberInput | ||
slots={{ | ||
root: StyledInputRoot, | ||
input: StyledInputElement, | ||
incrementButton: StyledButton, | ||
decrementButton: StyledButton, | ||
}} | ||
slotProps={{ | ||
incrementButton: { | ||
children: <span className="arrow">▴</span>, | ||
}, | ||
decrementButton: { | ||
children: <span className="arrow">▾</span>, | ||
}, | ||
}} | ||
{...props} | ||
ref={ref} | ||
/> | ||
); | ||
}); | ||
|
||
export default function NumberInputAdornments() { | ||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: { xs: 'column', sm: 'row' }, | ||
gap: 2, | ||
}} | ||
> | ||
<CustomNumberInput | ||
startAdornment={ | ||
<InputAdornment> | ||
<svg | ||
// From Feather: https://feathericons.com/?query=dollar-sign | ||
xmlns="http://www.w3.org/2000/svg" | ||
height="18" | ||
viewBox="0 0 24 24" | ||
width="18" | ||
fill="none" | ||
stroke="currentColor" | ||
strokeWidth="2.5" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
> | ||
<path d="M12 1v22M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" /> | ||
</svg> | ||
</InputAdornment> | ||
} | ||
/> | ||
<CustomNumberInput endAdornment={<InputAdornment>kg</InputAdornment>} /> | ||
</Box> | ||
); | ||
} | ||
|
||
const InputAdornment = styled('div')( | ||
({ theme }) => ` | ||
margin: 8px; | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
grid-row: 1/3; | ||
color: ${theme.palette.mode === 'dark' ? grey[500] : grey[700]}; | ||
`, | ||
); | ||
|
||
const blue = { | ||
100: '#DAECFF', | ||
200: '#b6daff', | ||
400: '#3399FF', | ||
500: '#007FFF', | ||
600: '#0072E5', | ||
900: '#003A75', | ||
}; | ||
|
||
const grey = { | ||
50: '#f6f8fa', | ||
100: '#eaeef2', | ||
200: '#d0d7de', | ||
300: '#afb8c1', | ||
400: '#8c959f', | ||
500: '#6e7781', | ||
600: '#57606a', | ||
700: '#424a53', | ||
800: '#32383f', | ||
900: '#24292f', | ||
}; | ||
|
||
const StyledInputRoot = styled('div')( | ||
({ theme }) => ` | ||
font-family: IBM Plex Sans, sans-serif; | ||
font-weight: 400; | ||
border-radius: 8px; | ||
color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; | ||
background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; | ||
border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; | ||
display: grid; | ||
grid-template-columns: auto 1fr auto 19px; | ||
grid-template-rows: 1fr 1fr; | ||
overflow: hidden; | ||
&.${numberInputClasses.focused} { | ||
border-color: ${blue[400]}; | ||
box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; | ||
} | ||
&:hover { | ||
border-color: ${blue[400]}; | ||
} | ||
// firefox | ||
&:focus-visible { | ||
outline: 0; | ||
} | ||
`, | ||
); | ||
|
||
const StyledInputElement = styled('input')` | ||
font-size: 0.875rem; | ||
font-family: inherit; | ||
font-weight: 400; | ||
line-height: 1.5; | ||
grid-row: 1/3; | ||
color: inherit; | ||
background: inherit; | ||
border: none; | ||
border-radius: inherit; | ||
padding: 8px 12px; | ||
outline: 0; | ||
`; | ||
|
||
const StyledButton = styled('button')( | ||
({ theme }) => ` | ||
display: flex; | ||
flex-flow: row nowrap; | ||
justify-content: center; | ||
align-items: center; | ||
appearance: none; | ||
padding: 0; | ||
width: 19px; | ||
height: 19px; | ||
font-family: system-ui, sans-serif; | ||
font-size: 0.875rem; | ||
line-height: 1; | ||
box-sizing: border-box; | ||
background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; | ||
border: 0; | ||
color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; | ||
transition-property: all; | ||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); | ||
transition-duration: 120ms; | ||
&:hover { | ||
background: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; | ||
border-color: ${theme.palette.mode === 'dark' ? grey[600] : grey[300]}; | ||
cursor: pointer; | ||
} | ||
&.${numberInputClasses.incrementButton} { | ||
grid-column: 4/5; | ||
grid-row: 1/2; | ||
} | ||
&.${numberInputClasses.decrementButton} { | ||
grid-column: 4/5; | ||
grid-row: 2/3; | ||
} | ||
& .arrow { | ||
transform: translateY(-1px); | ||
} | ||
`, | ||
); |
189 changes: 189 additions & 0 deletions
189
docs/data/base/components/number-input/NumberInputAdornments.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,189 @@ | ||
import * as React from 'react'; | ||
import { | ||
Unstable_NumberInput as NumberInput, | ||
NumberInputProps, | ||
numberInputClasses, | ||
} from '@mui/base/Unstable_NumberInput'; | ||
import Box from '@mui/material/Box'; | ||
import { styled } from '@mui/system'; | ||
|
||
const CustomNumberInput = React.forwardRef(function CustomNumberInput( | ||
props: NumberInputProps, | ||
ref: React.ForwardedRef<HTMLDivElement>, | ||
) { | ||
return ( | ||
<NumberInput | ||
slots={{ | ||
root: StyledInputRoot, | ||
input: StyledInputElement, | ||
incrementButton: StyledButton, | ||
decrementButton: StyledButton, | ||
}} | ||
slotProps={{ | ||
incrementButton: { | ||
children: <span className="arrow">▴</span>, | ||
}, | ||
decrementButton: { | ||
children: <span className="arrow">▾</span>, | ||
}, | ||
}} | ||
{...props} | ||
ref={ref} | ||
/> | ||
); | ||
}); | ||
|
||
export default function NumberInputAdornments() { | ||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: { xs: 'column', sm: 'row' }, | ||
gap: 2, | ||
}} | ||
> | ||
<CustomNumberInput | ||
startAdornment={ | ||
<InputAdornment> | ||
<svg | ||
// From Feather: https://feathericons.com/?query=dollar-sign | ||
xmlns="http://www.w3.org/2000/svg" | ||
height="18" | ||
viewBox="0 0 24 24" | ||
width="18" | ||
fill="none" | ||
stroke="currentColor" | ||
strokeWidth="2.5" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
> | ||
<path d="M12 1v22M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" /> | ||
</svg> | ||
</InputAdornment> | ||
} | ||
/> | ||
<CustomNumberInput endAdornment={<InputAdornment>kg</InputAdornment>} /> | ||
</Box> | ||
); | ||
} | ||
|
||
const InputAdornment = styled('div')( | ||
({ theme }) => ` | ||
margin: 8px; | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
grid-row: 1/3; | ||
color: ${theme.palette.mode === 'dark' ? grey[500] : grey[700]}; | ||
`, | ||
); | ||
|
||
const blue = { | ||
100: '#DAECFF', | ||
200: '#b6daff', | ||
400: '#3399FF', | ||
500: '#007FFF', | ||
600: '#0072E5', | ||
900: '#003A75', | ||
}; | ||
|
||
const grey = { | ||
50: '#f6f8fa', | ||
100: '#eaeef2', | ||
200: '#d0d7de', | ||
300: '#afb8c1', | ||
400: '#8c959f', | ||
500: '#6e7781', | ||
600: '#57606a', | ||
700: '#424a53', | ||
800: '#32383f', | ||
900: '#24292f', | ||
}; | ||
|
||
const StyledInputRoot = styled('div')( | ||
({ theme }) => ` | ||
font-family: IBM Plex Sans, sans-serif; | ||
font-weight: 400; | ||
border-radius: 8px; | ||
color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; | ||
background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; | ||
border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; | ||
display: grid; | ||
grid-template-columns: auto 1fr auto 19px; | ||
grid-template-rows: 1fr 1fr; | ||
overflow: hidden; | ||
&.${numberInputClasses.focused} { | ||
border-color: ${blue[400]}; | ||
box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; | ||
} | ||
&:hover { | ||
border-color: ${blue[400]}; | ||
} | ||
// firefox | ||
&:focus-visible { | ||
outline: 0; | ||
} | ||
`, | ||
); | ||
|
||
const StyledInputElement = styled('input')` | ||
font-size: 0.875rem; | ||
font-family: inherit; | ||
font-weight: 400; | ||
line-height: 1.5; | ||
grid-row: 1/3; | ||
color: inherit; | ||
background: inherit; | ||
border: none; | ||
border-radius: inherit; | ||
padding: 8px 12px; | ||
outline: 0; | ||
`; | ||
|
||
const StyledButton = styled('button')( | ||
({ theme }) => ` | ||
display: flex; | ||
flex-flow: row nowrap; | ||
justify-content: center; | ||
align-items: center; | ||
appearance: none; | ||
padding: 0; | ||
width: 19px; | ||
height: 19px; | ||
font-family: system-ui, sans-serif; | ||
font-size: 0.875rem; | ||
line-height: 1; | ||
box-sizing: border-box; | ||
background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; | ||
border: 0; | ||
color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; | ||
transition-property: all; | ||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); | ||
transition-duration: 120ms; | ||
&:hover { | ||
background: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; | ||
border-color: ${theme.palette.mode === 'dark' ? grey[600] : grey[300]}; | ||
cursor: pointer; | ||
} | ||
&.${numberInputClasses.incrementButton} { | ||
grid-column: 4/5; | ||
grid-row: 1/2; | ||
} | ||
&.${numberInputClasses.decrementButton} { | ||
grid-column: 4/5; | ||
grid-row: 2/3; | ||
} | ||
& .arrow { | ||
transform: translateY(-1px); | ||
} | ||
`, | ||
); |
Oops, something went wrong.