Skip to content

Commit

Permalink
Merge branch 'develop' into ee/alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
edburyenegren-okta committed Jun 9, 2023
2 parents eea6e40 + cd98022 commit 51898ec
Show file tree
Hide file tree
Showing 21 changed files with 95 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ jobs:
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ env.URL_STORYBOOK }}

- name: a11y test
run: yarn workspace @okta/odyssey-storybook test:storybook --url ${{ env.URL_STORYBOOK }}
- name: visual regression test
if: steps.changes.outputs.vrt == 'true'
env:
Expand Down
2 changes: 2 additions & 0 deletions packages/odyssey-react-mui/src/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ const Autocomplete = <

return (
<MuiAutocomplete
// AutoComplete is wrapped in a div within MUI which does not get the disabled attr. So this aria-disabled gets set in the div
aria-disabled={isDisabled}
disabled={isDisabled}
freeSolo={isCustomValueAllowed}
loading={isLoading}
Expand Down
12 changes: 12 additions & 0 deletions packages/odyssey-react-mui/src/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export type ButtonProps = {
*/
tooltipText?: string;
variant?: "primary" | "secondary" | "danger" | "floating";
ariaLabel?: string;
ariaLabelledBy?: string;
ariaDescribedBy?: string;
};

const Button = ({
Expand All @@ -45,13 +48,19 @@ const Button = ({
text,
tooltipText,
variant,
ariaLabel,
ariaLabelledBy,
ariaDescribedBy,
}: ButtonProps) => {
const muiProps = useContext(MuiPropsContext);

const button = useMemo(
() => (
<MuiButton
{...muiProps}
aria-label={ariaLabel}
aria-labelledby={ariaLabelledBy}
aria-describedby={ariaDescribedBy}
disabled={isDisabled}
endIcon={endIcon}
fullWidth={isFullWidth}
Expand All @@ -75,6 +84,9 @@ const Button = ({
startIcon,
text,
variant,
ariaLabel,
ariaLabelledBy,
ariaDescribedBy,
]
);

Expand Down
1 change: 0 additions & 1 deletion packages/odyssey-react-mui/src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const Checkbox = ({
<FormControlLabel
aria-label={ariaLabel}
aria-labelledby={ariaLabelledBy}
aria-required={isRequired}
checked={isChecked}
className={isInvalid ? "Mui-error" : isValid ? "Mui-valid" : ""}
control={
Expand Down
7 changes: 6 additions & 1 deletion packages/odyssey-react-mui/src/CircularProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ import { CircularProgress as MuiCircularProgress } from "@mui/material";

export type CircularProgressProps = {
value?: number;
ariaLabel?: string;
};

export const CircularProgress = ({ value }: CircularProgressProps) => (
export const CircularProgress = ({
value,
ariaLabel,
}: CircularProgressProps) => (
<MuiCircularProgress
value={value}
variant={value ? "determinate" : "indeterminate"}
aria-label={ariaLabel}
/>
);
8 changes: 0 additions & 8 deletions packages/odyssey-react-mui/src/Icon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,4 @@ describe("Icon", () => {
<Icon name={name} children="child" />
);
});

/* NOTE: the DOM output here is valid and a11y but we're seeing a violation:
https://dequeuniversity.com/rules/axe/4.2/svg-img-alt
a11yCheck(() => {
const ret = render(<Icon name={name} titleAccess={title} />)
});
*/
});
6 changes: 6 additions & 0 deletions packages/odyssey-react-mui/src/MenuButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export type MenuButtonProps = {
* The id of the `input` element.
*/
id?: string;
/**
* aria-label to describe the button when the button label is empty, e.g., an Icon only Button
*/
ariaLabel?: string;
};

const MenuButton = ({
Expand All @@ -53,6 +57,7 @@ const MenuButton = ({
buttonEndIcon = <ChevronDownIcon />,
buttonVariant = "secondary",
id: idOverride,
ariaLabel,
}: MenuButtonProps) => {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);

Expand Down Expand Up @@ -83,6 +88,7 @@ const MenuButton = ({
aria-expanded={open ? "true" : undefined}
onClick={handleClick}
text={buttonLabel}
ariaLabel={ariaLabel}
variant={buttonVariant}
/>
<Menu
Expand Down
4 changes: 2 additions & 2 deletions packages/odyssey-react-mui/src/OdysseyI18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import { translation as sv } from "./properties/ts/odyssey-react-mui_sv";
import { translation as th } from "./properties/ts/odyssey-react-mui_th";
import { translation as tr } from "./properties/ts/odyssey-react-mui_tr";
import { translation as uk } from "./properties/ts/odyssey-react-mui_uk";
import { translation as zhCN } from "./properties/ts/odyssey-react-mui_zh-CN";
import { translation as znTW } from "./properties/ts/odyssey-react-mui_zh-TW";
import { translation as zhCN } from "./properties/ts/odyssey-react-mui_zh_CN";
import { translation as znTW } from "./properties/ts/odyssey-react-mui_zh_TW";

import {
SupportedLanguages,
Expand Down
12 changes: 10 additions & 2 deletions packages/odyssey-react-mui/src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
* See the License for the specific language governing permissions and limitations under the License.
*/

import React, { ReactElement, ReactNode, useCallback, useState } from "react";
import React, {
ReactElement,
ReactNode,
memo,
useCallback,
useState,
} from "react";
import { Tab as MuiTab } from "@mui/material";
import {
TabList as MuiTabList,
Expand Down Expand Up @@ -67,4 +73,6 @@ const Tabs = ({ ariaLabel, tabs, initialValue = "0" }: TabsProps) => {
);
};

export { Tabs };
const MemoizedTabs = memo(Tabs);

export { MemoizedTabs as Tabs };
2 changes: 1 addition & 1 deletion packages/odyssey-react-mui/src/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const Toast = ({
action={
isDismissable === true && (
<Button
aria-label={t("toast.close.text")}
ariaLabel={t("toast.close.text")}
onClick={onHide}
size="small"
startIcon={<CloseIcon />}
Expand Down
28 changes: 0 additions & 28 deletions packages/odyssey-react-mui/src/a11yCheck.ts

This file was deleted.

Empty file.
Empty file.
7 changes: 4 additions & 3 deletions packages/odyssey-storybook/.storybook/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ module.exports = {
* The context argument is a Storybook object containing the story's id, title, and name.
*/
async postRender(page, context) {
await new Promise((r) => setTimeout(r, 500));

// https://github.com/abhinaba-ghosh/axe-playwright#parameters-on-checka11y-axerun
await checkA11y(
// the page instance of playwright
Expand All @@ -36,13 +38,12 @@ module.exports = {
detailedReport: true,
detailedReportOptions: {
// whether or not to include the full html for the offending nodes
html: false,
html: true,
},
},

// skipFailures
// FIXME set to false once a11y issues (in stories) have been resolved
true,
false,

// reporter "default" is terminal reporter, "html" writes results to file
"default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export const ButtonWithIcon: StoryObj<ButtonProps> = {
export const IconOnly: StoryObj<ButtonProps> = {
args: {
startIcon: <AddIcon />,
text: undefined, // FIXME
tooltipText: "Add crew", // FIXME
ariaLabel: "Add",
text: undefined,
tooltipText: "Add crew",
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ const storybookMeta: Meta<CircularProgressProps> = {
export default storybookMeta;

export const Indeterminate: StoryObj<CircularProgressProps> = {
args: {},
args: {
ariaLabel: "progress",
},
};

export const Determinate: StoryObj<CircularProgressProps> = {
args: {
value: 70,
ariaLabel: "progress",
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,6 @@ export const IconButton: StoryObj<MenuButtonProps> = {
],
buttonLabel: "",
buttonEndIcon: <OverflowVerticalIcon />,
ariaLabel: "Add",
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const storybookMeta: Meta<NativeSelectProps> = {
hint: "Select your destination in the Sol system.",
isOptional: false,
label: "Destination",
id: "SolarDestination",
},
decorators: [MuiThemeDecorator],
};
Expand All @@ -53,6 +54,7 @@ const Template: StoryObj<NativeSelectProps> = {
render: function C(args) {
return (
<NativeSelect
id={args.id}
label={args.label}
hint={args.hint}
defaultValue={args.defaultValue}
Expand Down Expand Up @@ -80,6 +82,7 @@ const GroupTemplate: StoryObj<NativeSelectProps> = {
render: function C(args) {
return (
<NativeSelect
id={args.id}
label={args.label}
hint={args.hint}
errorMessage={args.errorMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ function EnhancedTable() {
selected={isItemSelected}
>
<TableCell>
<Checkbox
ariaLabelledBy={labelId}
{/* <Checkbox
ariaLabel={labelId}
isChecked={isItemSelected}
/>
/> */}
</TableCell>
<TableCell id={labelId}>{row.name}</TableCell>
<TableCell variant="number">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
TabsProps,
Tabs,
} from "@okta/odyssey-react-mui";
import { useMemo } from "react";
import { MuiThemeDecorator } from "../../../../.storybook/components";

const storybookMeta: Meta<TabsProps & TabItemProps> = {
Expand All @@ -44,45 +43,43 @@ const storybookMeta: Meta<TabsProps & TabItemProps> = {

export default storybookMeta;

const ExampleTabContent = ({ label }: { label: string }) => {
return useMemo(() => <>{`Information about ${label}`}</>, [label]);
};

const DefaultTemplate: StoryObj<TabItemProps> = {
render: function C(args) {
const tabs: TabItemProps[] = [];

tabs.push({
label: "Planets",
value: "planets",
children: "Information about Planets.",
});
tabs.push({
label: "Moons",
value: "moons",
children: "Information about Moons.",
});

if (args?.label) {
tabs.push({
label: args.label,
value: args.value,
isDisabled: args.isDisabled,
startIcon: args.startIcon,
children: args.children,
});
}

return (
<Tabs
initialValue="planets"
ariaLabel="basic tabs example"
tabs={[
{
label: "Planets",
value: "planets",
children: "Information about Planets.",
},
{
label: "Moons",
value: "moons",
children: "Information about Moons.",
},
{
label: args.label,
value: args.value,
isDisabled: args.isDisabled,
startIcon: args.startIcon,
children: <ExampleTabContent label={args.label} />,
},
]}
/>
<Tabs initialValue="planets" ariaLabel="basic tabs example" tabs={tabs} />
);
},
};

const ExampleTabContent = ({ label }: { label: string }) => {
return <>Information about {label}</>;
};

export const Default: StoryObj<TabItemProps> = {
...DefaultTemplate,
args: {
//
},
};

export const Disabled: StoryObj<TabItemProps> = {
Expand All @@ -98,5 +95,6 @@ export const Icons: StoryObj<TabItemProps> = {
args: {
startIcon: <FavoriteIcon />,
label: "Icon Tab",
children: <ExampleTabContent label="Icon Tab" />,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ export const Default: StoryObj<TooltipProps> = {
export const Icon: StoryObj<TooltipProps> = {
...Template,
args: {
children: <Button variant="secondary" startIcon={<DownloadIcon />} />,
children: (
<Button
variant="secondary"
ariaLabel="Download logs"
startIcon={<DownloadIcon />}
/>
),
ariaType: "label",
placement: "top",
text: "Download logs",
Expand Down

0 comments on commit 51898ec

Please sign in to comment.