Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[joy-ui] Introduce color inversion utilities #38916

Merged
merged 91 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
5be363b
remove invertedColors
siriwatknp Aug 9, 2023
cedff7c
wip
siriwatknp Aug 9, 2023
0e9eae9
wip
siriwatknp Aug 17, 2023
e2ffae1
Merge branch 'master' of https://github.com/mui/material-ui into joy/…
siriwatknp Sep 11, 2023
1227a26
revert Alert
siriwatknp Sep 11, 2023
9916ecd
add scopedVariantVars
siriwatknp Sep 11, 2023
b9910f0
add to experiment apge
siriwatknp Sep 11, 2023
38a5bc3
Merge branch 'master' of https://github.com/mui/material-ui into joy/…
siriwatknp Sep 18, 2023
f680379
add data-inverted-colors for enabling the feature
siriwatknp Sep 18, 2023
eecf8e2
set instanceColor to required
siriwatknp Sep 18, 2023
0bc227e
update Accordion and ListItem
siriwatknp Sep 18, 2023
3f82b40
update AccordionDetails
siriwatknp Sep 18, 2023
27ff13e
update Card and ModalDialog
siriwatknp Sep 18, 2023
4d19830
update AccordionGroup and List
siriwatknp Sep 18, 2023
c40a7ed
update AccordionSummary and ListItemButton
siriwatknp Sep 18, 2023
b1bfd2e
update Alert
siriwatknp Sep 18, 2023
ca6d6a5
update AspectRatio
siriwatknp Sep 18, 2023
bfc6bff
update CircularProgress and Chip
siriwatknp Sep 18, 2023
6983dc6
update Autocomplete
siriwatknp Sep 18, 2023
56fcedf
move instanceColors before props
siriwatknp Sep 18, 2023
6614d0c
update AutocompleteListbox
siriwatknp Sep 18, 2023
2deafd0
update AutocompleteOption
siriwatknp Sep 18, 2023
4ff468f
update Avatar
siriwatknp Sep 18, 2023
f0864e6
update AvatarGroup
siriwatknp Sep 18, 2023
d1b6a07
update Badge
siriwatknp Sep 18, 2023
c79933a
update CardOverflow
siriwatknp Sep 18, 2023
e71bb28
update Checkbox
siriwatknp Sep 18, 2023
b39e29e
update ChipDelete and IconButton
siriwatknp Sep 18, 2023
d3ea964
update DialogTitle
siriwatknp Sep 18, 2023
ee23bef
update Drawer
siriwatknp Sep 18, 2023
1517bc6
update FormControl, Input, and LinearProgress
siriwatknp Sep 18, 2023
f47c0de
update ListSubheader
siriwatknp Sep 19, 2023
1e0c4f3
update Menu
siriwatknp Sep 19, 2023
8c0112c
update Menu components
siriwatknp Sep 19, 2023
eaeda28
update ModalClose
siriwatknp Sep 19, 2023
b0d2660
update Checkbox and Radio
siriwatknp Sep 19, 2023
ff789b0
update Option
siriwatknp Sep 19, 2023
9dd45ad
update ModalDialog
siriwatknp Sep 19, 2023
39f7275
update RadioGroup
siriwatknp Sep 19, 2023
cf7f6cd
update Select
siriwatknp Sep 19, 2023
fb49de0
update Sheet
siriwatknp Sep 19, 2023
328c5b6
update Slider
siriwatknp Sep 19, 2023
5344a20
update SvgIcon
siriwatknp Sep 19, 2023
60b0cb3
update Switch
siriwatknp Sep 19, 2023
9faa419
update Tab
siriwatknp Sep 19, 2023
631a7f4
update Table
siriwatknp Sep 19, 2023
f59f30d
update TabList
siriwatknp Sep 19, 2023
19d2fef
update TabPanel
siriwatknp Sep 19, 2023
9ee171b
update Tabs
siriwatknp Sep 19, 2023
eecee9d
update Textarea
siriwatknp Sep 19, 2023
929d48a
update ButtonGroup
siriwatknp Sep 19, 2023
a73f535
update Tooltip
siriwatknp Sep 19, 2023
504e6ab
update Link and Typography
siriwatknp Sep 19, 2023
fc02599
remove ColorInversionContext
siriwatknp Sep 19, 2023
818ccd1
remove instanceColor
siriwatknp Sep 19, 2023
0afcb2b
revert changes
siriwatknp Sep 19, 2023
c1831ea
Merge branch 'master' of https://github.com/mui/material-ui into joy/…
siriwatknp Sep 19, 2023
d9ebd2f
remove unused import
siriwatknp Sep 19, 2023
70ad11f
remove line break
siriwatknp Sep 19, 2023
2aa0496
fix focusedHighlight
siriwatknp Sep 19, 2023
5bfe6b6
use data-skip-inverted-colors
siriwatknp Sep 19, 2023
141f0c6
Fix all components
siriwatknp Sep 20, 2023
5f0e20e
remove describeColorInversion
siriwatknp Sep 20, 2023
a4dd340
fix test
siriwatknp Sep 20, 2023
b781b3b
wip docs
siriwatknp Sep 20, 2023
bac961a
revert change
siriwatknp Sep 20, 2023
11dc414
run proptypes and docs:api
siriwatknp Sep 20, 2023
d158694
wip
siriwatknp Sep 21, 2023
34cae0d
Merge branch 'master' of https://github.com/mui/material-ui into joy/…
siriwatknp Sep 22, 2023
5c26e0d
Revert "wip"
siriwatknp Sep 22, 2023
7263b00
wip
siriwatknp Sep 23, 2023
e280324
update apply color inversion functions
siriwatknp Sep 24, 2023
2be1036
revert change
siriwatknp Sep 24, 2023
63cefff
Merge branch 'master' of https://github.com/mui/material-ui into joy/…
siriwatknp Sep 24, 2023
4ae060f
fix type error
siriwatknp Sep 24, 2023
17d93a7
remove unused import
siriwatknp Sep 24, 2023
368d98a
fix icon color and update demos
siriwatknp Sep 24, 2023
94be635
Merge branch 'master' of https://github.com/mui/material-ui into joy/…
siriwatknp Sep 28, 2023
f50e80e
revert
siriwatknp Sep 28, 2023
d221a58
combine :not
siriwatknp Sep 28, 2023
a28dec3
update color inversion docs
siriwatknp Sep 28, 2023
a922bc3
move color inversion to a dedicated folder
siriwatknp Sep 29, 2023
645f59a
add demos
siriwatknp Sep 29, 2023
383fd8f
add tests
siriwatknp Sep 29, 2023
2de1fc0
add regression
siriwatknp Sep 29, 2023
e7f6e43
add spec
siriwatknp Sep 29, 2023
3c285cf
run scripts
siriwatknp Sep 29, 2023
991888f
Merge branch 'master' of https://github.com/mui/material-ui into joy/…
siriwatknp Sep 29, 2023
ee867ef
update doc
siriwatknp Oct 4, 2023
7ae2f38
Merge branch 'master' of https://github.com/mui/material-ui into joy/…
siriwatknp Oct 4, 2023
394f4e0
fix Switch
siriwatknp Oct 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ export default extendTheme({
JoyInput: {
styleOverrides: {
root: ({ ownerState, theme }) => ({
...(ownerState.variant === 'outlined' &&
ownerState.color !== 'context' && {
[`&:not(.${inputClasses.focused}):hover::before`]: {
boxShadow: `inset 0 0 0 2px ${
theme.vars.palette?.[ownerState.color!]?.outlinedBorder
}`,
},
}),
...(ownerState.variant === 'outlined' && {
[`&:not(.${inputClasses.focused}):hover::before`]: {
boxShadow: `inset 0 0 0 2px ${
theme.vars.palette?.[ownerState.color!]?.outlinedBorder
}`,
},
}),
}),
input: {
caretColor: 'var(--Input-focusedHighlight)',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { applySolidInversion } from '@mui/joy/colorInversion';
import Box from '@mui/joy/Box';
import Button from '@mui/joy/Button';
import Typography from '@mui/joy/Typography';

function Stat({ description, value, sx, ...props }) {
return (
<Box
{...props}
sx={[
{ borderLeft: 3, borderColor: 'divider', px: 2, py: 0.5 },
...(Array.isArray(sx) ? sx : [sx]),
]}
>
<Typography level="h3" component="div">
{value}
</Typography>
<Typography level="title-sm" textColor="text.secondary">
{description}
</Typography>
</Box>
);
}

Stat.propTypes = {
description: PropTypes.node,
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([
PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool]),
),
PropTypes.func,
PropTypes.object,
]),
value: PropTypes.node,
};

export default function ColorInversionAnyParent() {
return (
<Box
sx={[
{
display: 'grid',
gridTemplateColumns: { sm: '1fr 1fr' },
alignItems: 'center',
rowGap: 2,
columnGap: 8,
p: 2,
background: (theme) =>
`linear-gradient(45deg, ${theme.vars.palette.neutral[800]}, ${theme.vars.palette.neutral[600]})`,
borderRadius: 'sm',
},
applySolidInversion('neutral'),
]}
>
<div>
<Typography sx={{ my: 2 }}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.
</Typography>
<Button variant="soft" sx={{ mt: 1 }}>
Learn more
</Button>
</div>
<Box
sx={{
display: 'grid',
gridTemplateColumns: {
xs: 'repeat(auto-fill, minmax(min(100%, 180px), 1fr))',
sm: '1fr 1fr',
},
gap: 3,
}}
>
<Stat value="4M" description="Weekly download on NPM" />
<Stat value="87k" description="Stars on Github" />
<Stat value="2.7k" description="Open source contributors" />
<Stat value="18.4k" description="Followers on Twitter" />
</Box>
</Box>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import * as React from 'react';
import { applySolidInversion } from '@mui/joy/colorInversion';
import Box, { BoxProps } from '@mui/joy/Box';
import Button from '@mui/joy/Button';
import Typography from '@mui/joy/Typography';

function Stat({
description,
value,
sx,
...props
}: {
description: React.ReactNode;
value: React.ReactNode;
} & BoxProps) {
return (
<Box
{...props}
sx={[
{ borderLeft: 3, borderColor: 'divider', px: 2, py: 0.5 },
...(Array.isArray(sx) ? sx : [sx]),
]}
>
<Typography level="h3" component="div">
{value}
</Typography>
<Typography level="title-sm" textColor="text.secondary">
{description}
</Typography>
</Box>
);
}

export default function ColorInversionAnyParent() {
return (
<Box
sx={[
{
display: 'grid',
gridTemplateColumns: { sm: '1fr 1fr' },
alignItems: 'center',
rowGap: 2,
columnGap: 8,
p: 2,
background: (theme) =>
`linear-gradient(45deg, ${theme.vars.palette.neutral[800]}, ${theme.vars.palette.neutral[600]})`,
borderRadius: 'sm',
},
applySolidInversion('neutral'),
]}
>
<div>
<Typography sx={{ my: 2 }}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.
</Typography>
<Button variant="soft" sx={{ mt: 1 }}>
Learn more
</Button>
</div>
<Box
sx={{
display: 'grid',
gridTemplateColumns: {
xs: 'repeat(auto-fill, minmax(min(100%, 180px), 1fr))',
sm: '1fr 1fr',
},
gap: 3,
}}
>
<Stat value="4M" description="Weekly download on NPM" />
<Stat value="87k" description="Stars on Github" />
<Stat value="2.7k" description="Open source contributors" />
<Stat value="18.4k" description="Followers on Twitter" />
</Box>
</Box>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ export default function ColorInversionNavigation() {
<SmsIcon />
</ListItemDecorator>
Chat
<Chip size="sm" color="warning" variant="soft" sx={{ ml: 'auto' }}>
<Chip
data-skip-inverted-colors
size="sm"
color="warning"
variant="soft"
sx={{ ml: 'auto' }}
>
5
</Chip>
</ListItemButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ export default function ColorInversionNavigation() {
<SmsIcon />
</ListItemDecorator>
Chat
<Chip size="sm" color="warning" variant="soft" sx={{ ml: 'auto' }}>
<Chip
data-skip-inverted-colors
size="sm"
color="warning"
variant="soft"
sx={{ ml: 'auto' }}
>
5
</Chip>
</ListItemButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ export default function ColorInversionOverview() {
>
<BookmarkOutlinedIcon />
</IconButton>
<Typography fontSize="xl2" fontWeight="lg">
Learn how to build super fast websites.
</Typography>
<Typography level="h3">Learn how to build super fast websites.</Typography>
<Button variant="solid" endDecorator={<KeyboardArrowRightIcon />}>
Read more
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ export default function ColorInversionOverview() {
>
<BookmarkOutlinedIcon />
</IconButton>
<Typography fontSize="xl2" fontWeight="lg">
Learn how to build super fast websites.
</Typography>
<Typography level="h3">Learn how to build super fast websites.</Typography>
<Button variant="solid" endDecorator={<KeyboardArrowRightIcon />}>
Read more
</Button>
Expand Down
62 changes: 62 additions & 0 deletions docs/data/joy/main-features/color-inversion/ColorInversionSkip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import * as React from 'react';
import AspectRatio from '@mui/joy/AspectRatio';
import Card from '@mui/joy/Card';
import SvgIcon from '@mui/joy/SvgIcon';
import IconButton from '@mui/joy/IconButton';
import Typography from '@mui/joy/Typography';
import ArrowForward from '@mui/icons-material/ArrowForward';

export default function ColorInversionSkip() {
return (
<Card
size="lg"
variant="solid"
color="neutral"
invertedColors
sx={{ maxWidth: 300, boxShadow: 'lg', borderRadius: 'xl' }}
>
<AspectRatio
data-skip-inverted-colors
variant="soft"
color="success"
ratio="1"
sx={{ width: 48 }}
>
<div>
<SvgIcon>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<rect x="3" y="8" width="18" height="4" rx="1" />
<path d="M12 8v13" />
<path d="M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7" />
<path d="M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5" />
</svg>
</SvgIcon>
</div>
</AspectRatio>

<Typography level="h3">Design Thinking</Typography>
<Typography level="body-sm">
How to apply design thinking to your problem in order to generate innovative
and user-centric solutions.
</Typography>

<IconButton
variant="plain"
size="lg"
sx={{ alignSelf: 'flex-end', borderRadius: '50%', mr: -1, my: -1 }}
>
<ArrowForward />
</IconButton>
</Card>
);
}
62 changes: 62 additions & 0 deletions docs/data/joy/main-features/color-inversion/ColorInversionSkip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import * as React from 'react';
import AspectRatio from '@mui/joy/AspectRatio';
import Card from '@mui/joy/Card';
import SvgIcon from '@mui/joy/SvgIcon';
import IconButton from '@mui/joy/IconButton';
import Typography from '@mui/joy/Typography';
import ArrowForward from '@mui/icons-material/ArrowForward';

export default function ColorInversionSkip() {
return (
<Card
size="lg"
variant="solid"
color="neutral"
invertedColors
sx={{ maxWidth: 300, boxShadow: 'lg', borderRadius: 'xl' }}
>
<AspectRatio
data-skip-inverted-colors
variant="soft"
color="success"
ratio="1"
sx={{ width: 48 }}
>
<div>
<SvgIcon>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<rect x="3" y="8" width="18" height="4" rx="1" />
<path d="M12 8v13" />
<path d="M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7" />
<path d="M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5" />
</svg>
</SvgIcon>
</div>
</AspectRatio>

<Typography level="h3">Design Thinking</Typography>
<Typography level="body-sm">
How to apply design thinking to your problem in order to generate innovative
and user-centric solutions.
</Typography>

<IconButton
variant="plain"
size="lg"
sx={{ alignSelf: 'flex-end', borderRadius: '50%', mr: -1, my: -1 }}
>
<ArrowForward />
</IconButton>
</Card>
);
}
Loading