Skip to content

Commit

Permalink
Merge pull request #1877 from okta/ee/tabs
Browse files Browse the repository at this point in the history
refactor(odyssey-react-mui): update Tab/Tabs styling
  • Loading branch information
edburyenegren-okta authored Jul 12, 2023
2 parents 2957e6a + 807ec54 commit 6b07b85
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 31 deletions.
37 changes: 19 additions & 18 deletions packages/odyssey-react-mui/src/theme/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1855,22 +1855,33 @@ export const components = (
minWidth: "unset",
minHeight: "unset",
padding: `${odysseyTokens.Spacing4} 0`,
lineHeight: odysseyTokens.TypographyLineHeightBody,
fontFamily: odysseyTokens.TypographyFamilyHeading,
lineHeight: odysseyTokens.TypographyLineHeightUi,
overflow: "visible",
...(ownerState.selected == true && {
color: odysseyTokens.TypographyColorBody,
}),

...(ownerState.textColor === "inherit" && {
color: "inherit",
opacity: 1,
}),

...(ownerState.selected == true && {
color: odysseyTokens.TypographyColorAction,
fontWeight: odysseyTokens.TypographyWeightBodyBold,
}),

...(ownerState.disabled && {
color: odysseyTokens.TypographyColorDisabled,
}),

...(ownerState.wrapped && {
fontSize: odysseyTokens.TypographySizeCaption,
lineHeight: theme.typography.subtitle1.lineHeight,
}),

"&:hover": {
color: odysseyTokens.TypographyColorAction,
},

"&:focus-visible::before, &.Mui-focusVisible::before": {
content: "''",
position: "absolute",
Expand All @@ -1883,20 +1894,7 @@ export const components = (
borderColor: odysseyTokens.PalettePrimaryMain,
borderRadius: odysseyTokens.BorderRadiusMain,
},
"&.Mui-selected": {
color: odysseyTokens.TypographyColorBody,
fontWeight: odysseyTokens.TypographyWeightBodyBold,
"&:hover": {
color: odysseyTokens.TypographyColorAction,
},
},
"&.Mui-disabled": {
cursor: "not-allowed",
pointerEvents: "unset",
"&:hover": {
color: odysseyTokens.TypographyColorDisabled,
},
},

"& .MuiTab-iconWrapper": {
marginInlineEnd: odysseyTokens.Spacing1,
},
Expand Down Expand Up @@ -2133,6 +2131,9 @@ export const components = (
},
},
MuiTabs: {
defaultProps: {
textColor: "inherit",
},
styleOverrides: {
root: {
minHeight: "unset",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import { Meta, StoryObj } from "@storybook/react";

import {
FavoriteIcon,
BugIcon,
TabItemProps,
TabsProps,
Tabs,
Expand All @@ -22,7 +22,6 @@ import { MuiThemeDecorator } from "../../../../.storybook/components";
import { userEvent, waitFor, within } from "@storybook/testing-library";
import { expect } from "@storybook/jest";
import { axeRun } from "../../../axe-util";
import { screen } from "@storybook/testing-library";
import type { PlaywrightProps } from "../storybookTypes";
import { icons } from "../../../../.storybook/components/iconUtils";

Expand Down Expand Up @@ -104,13 +103,6 @@ const selectTab =
userEvent.tab();
const tabData = canvas.getByText(`Information about ${tabName}`);
expect(tabData).toBeInTheDocument();

if (actionName === "Tab Disabled") {
const disabledTab = canvas.getByText("Disabled Tab");
userEvent.click(disabledTab);
const tabData = screen.queryByText("Tab is disabled");
expect(tabData).not.toBeInTheDocument();
}
});
});
};
Expand Down Expand Up @@ -172,11 +164,11 @@ export const Disabled: StoryObj<TabItemProps> = {
export const Icons: StoryObj<TabItemProps> = {
...DefaultTemplate,
args: {
startIcon: <FavoriteIcon />,
label: "Icon Tab",
children: <ExampleTabContent label="Icon Tab" />,
startIcon: <BugIcon />,
label: "Xenomorphs",
children: <ExampleTabContent label="Xenomorphs" />,
},
play: async ({ canvasElement, step }) => {
selectTab({ canvasElement, step })("Tab Icon", "Icon Tab");
selectTab({ canvasElement, step })("Tab Icon", "Xenomorphs");
},
};

0 comments on commit 6b07b85

Please sign in to comment.