Skip to content

Commit

Permalink
[docs][joy-ui] Make code readable to set next color in color inversio…
Browse files Browse the repository at this point in the history
…n demos (mui#39669)
  • Loading branch information
ZeeshanTamboli authored Nov 3, 2023
1 parent a459e2f commit d37b6cc
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export default function ColorInversionFooter() {
onClick={() => {
const colors = ['primary', 'neutral', 'danger', 'success', 'warning'];

const nextColor = colors.indexOf(color);
setColor(colors[nextColor + 1] ?? colors[0]);
const nextColorIndex = colors.indexOf(color) + 1;
setColor(colors[nextColorIndex] ?? colors[0]);
}}
>
<ColorLensRoundedIcon fontSize="small" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default function ColorInversionFooter() {
'success',
'warning',
];
const nextColor = colors.indexOf(color);
setColor(colors[nextColor + 1] ?? colors[0]);
const nextColorIndex = colors.indexOf(color) + 1;
setColor(colors[nextColorIndex] ?? colors[0]);
}}
>
<ColorLensRoundedIcon fontSize="small" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export default function ColorInversionHeader() {
onClick={() => {
const colors = ['primary', 'neutral', 'danger', 'success', 'warning'];

const nextColor = colors.indexOf(color);
setColor(colors[nextColor + 1] ?? colors[0]);
const nextColorIndex = colors.indexOf(color) + 1;
setColor(colors[nextColorIndex] ?? colors[0]);
}}
>
<ColorLensRoundedIcon fontSize="small" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export default function ColorInversionHeader() {
'success',
'warning',
];
const nextColor = colors.indexOf(color);
setColor(colors[nextColor + 1] ?? colors[0]);
const nextColorIndex = colors.indexOf(color) + 1;
setColor(colors[nextColorIndex] ?? colors[0]);
}}
>
<ColorLensRoundedIcon fontSize="small" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export default function ColorInversionMarketing() {
onClick={() => {
const colors = ['primary', 'neutral', 'danger', 'success', 'warning'];

const nextColor = colors.indexOf(color);
setColor(colors[nextColor + 1] ?? colors[0]);
const nextColorIndex = colors.indexOf(color) + 1;
setColor(colors[nextColorIndex] ?? colors[0]);
}}
>
<ColorLensRoundedIcon fontSize="small" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export default function ColorInversionMarketing() {
'success',
'warning',
];
const nextColor = colors.indexOf(color);
setColor(colors[nextColor + 1] ?? colors[0]);
const nextColorIndex = colors.indexOf(color) + 1;
setColor(colors[nextColorIndex] ?? colors[0]);
}}
>
<ColorLensRoundedIcon fontSize="small" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ export default function ColorInversionNavigation() {
onClick={() => {
const colors = ['primary', 'neutral', 'danger', 'success', 'warning'];

const nextColor = colors.indexOf(color);
setColor(colors[nextColor + 1] ?? colors[0]);
const nextColorIndex = colors.indexOf(color) + 1;
setColor(colors[nextColorIndex] ?? colors[0]);
}}
sx={{ mt: 'auto', height: '40px' }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ export default function ColorInversionNavigation() {
'success',
'warning',
];
const nextColor = colors.indexOf(color);
setColor(colors[nextColor + 1] ?? colors[0]);
const nextColorIndex = colors.indexOf(color) + 1;
setColor(colors[nextColorIndex] ?? colors[0]);
}}
sx={{ mt: 'auto', height: '40px' }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export default function ColorInversionPopup() {
onClick={() => {
const colors = ['primary', 'neutral', 'danger', 'success', 'warning'];

const nextColor = colors.indexOf(color);
setColor(colors[nextColor + 1] ?? colors[0]);
const nextColorIndex = colors.indexOf(color) + 1;
setColor(colors[nextColorIndex] ?? colors[0]);
}}
>
Change the color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export default function ColorInversionPopup() {
'success',
'warning',
];
const nextColor = colors.indexOf(color);
setColor(colors[nextColor + 1] ?? colors[0]);
const nextColorIndex = colors.indexOf(color) + 1;
setColor(colors[nextColorIndex] ?? colors[0]);
}}
>
Change the color
Expand Down

0 comments on commit d37b6cc

Please sign in to comment.