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

feat: Misc Odyssey updates #2326

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions packages/odyssey-react-mui/src/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ export type AutocompleteProps<
undefined,
IsCustomValueAllowed
>["defaultValue"];
/**
* The default value. Use when the component is not controlled.
*/
getOptionLabel?: UseAutocompleteProps<
OptionType,
HasMultipleChoices,
undefined,
IsCustomValueAllowed
>["getOptionLabel"];
KevinGhadyani-Okta marked this conversation as resolved.
Show resolved Hide resolved
/**
* Enables multiple choice selection
*/
Expand Down Expand Up @@ -217,6 +226,7 @@ const Autocomplete = <
defaultValue,
errorMessage,
errorMessageList,
getOptionLabel,
hasMultipleChoices,
id: idOverride,
inputValue,
Expand Down Expand Up @@ -539,6 +549,7 @@ const Autocomplete = <
disabled={isDisabled}
freeSolo={isCustomValueAllowed}
filterSelectedOptions={true}
getOptionLabel={getOptionLabel}
id={idOverride}
fullWidth={isFullWidth}
loading={isLoading}
Expand Down
134 changes: 134 additions & 0 deletions packages/odyssey-react-mui/src/Grid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*!
* Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and limitations under the License.
*/

import { memo } from "react";
import { Grid as MuiGrid, GridProps as MuiGridProps } from "@mui/material";

type GridBreakpoints = {
/**
* If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `lg` breakpoint and wider screens if not overridden.
*/
lg?: MuiGridProps["lg"];
/**
* If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `md` breakpoint and wider screens if not overridden.
*/
md?: MuiGridProps["md"];
/**
* If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `sm` breakpoint and wider screens if not overridden.
*/
sm?: MuiGridProps["sm"];
/**
* If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for all the screen sizes with the lowest priority.
*/
xs?: MuiGridProps["xs"];
};

export type GridProps = {
/**
* The `Grid` content. Will be made up of `<Grid item />` components
*/
children: MuiGridProps["children"];
/**
* The number of columns.
*/
columns?: MuiGridProps["columns"];
/**
* The component used for the root node. Either a string to use a HTML element or a component.
*/
component?: MuiGridProps["component"];
/**
* If true, the component will have the flex container behavior. You should be wrapping items with a container.
*/
container?: MuiGridProps["container"];
/**
* Defines the horizontal space between the type item components. It overrides the value of the spacing prop.
*/
columnSpacing?: MuiGridProps["columnSpacing"];
/**
* Defines the flex-direction style property. It is applied for all screen sizes.
*/
direction?: MuiGridProps["direction"];
/**
* designates the `Grid` component as a child item of it's parent container
*/
item?: MuiGridProps["item"];
/**
* Defines the vertical space between the type item components. It overrides the value of the spacing prop.
*/
rowSpacing?: MuiGridProps["rowSpacing"];
/**
* Defines the space between the type item components. It can only be used on a type container component.
*/
spacing?: MuiGridProps["spacing"];
};

export type GridContainerProps = Pick<
GridProps,
| "children"
| "component"
| "columnSpacing"
| "direction"
| "rowSpacing"
| "spacing"
>;

export type GridItemProps = Pick<GridProps, "children" | "component"> &
GridBreakpoints;

const Grid = ({
children,
columns,
component = "div",
container,
direction,
item,
rowSpacing,
spacing,
}: GridProps) => {
return (
<MuiGrid
columns={columns}
container={container}
component={component}
direction={direction}
Comment on lines +87 to +102
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a Storybook entry for Grid? I'm not sure I completely understand what it does without seeing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's a direct port of a MUI component, I didn't think we'd want a story for it. What do you think?

item={item}
rowSpacing={rowSpacing}
spacing={spacing}
>
{children}
</MuiGrid>
);
};

const GridContainer = ({ children, ...props }: GridContainerProps) => {
return (
<Grid container {...props}>
{children}
</Grid>
);
};

const GridItem = ({ children, ...props }: GridItemProps) => {
return (
<Grid item {...props}>
{children}
</Grid>
);
};

const MemoizedGridContainer = memo(GridContainer);
MemoizedGridContainer.displayName = "GridContainer";

const MemoizedGridItem = memo(GridItem);
MemoizedGridItem.displayName = "GridItem";

export { MemoizedGridContainer as GridContainer, MemoizedGridItem as GriItem };
39 changes: 39 additions & 0 deletions packages/odyssey-react-mui/src/Stack.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*!
* Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and limitations under the License.
*/

import { memo } from "react";
import { Stack as MuiStack, StackProps as MuiStackProps } from "@mui/material";

export type StackProps = {
children?: MuiStackProps["children"];
/**
* The component used for the root node. Either a string to use a HTML element or a component.
*/
component?: MuiStackProps["component"];
/**
* Defines the flex-direction style property. It is applied for all screen sizes.
*/
direction?: MuiStackProps["direction"];
/**
* Defines the space between immediate children.
*/
spacing?: MuiStackProps["spacing"];
};

const Stack = ({ children, spacing }: StackProps) => {
return <MuiStack spacing={spacing}>{children}</MuiStack>;
};
Comment on lines +32 to +34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the spacing stuff we're missing from Gen2? Can we get a Storybook entry for it?


const MemoizedStack = memo(Stack);
MemoizedStack.displayName = "Stack";

export { MemoizedStack as Stack };
6 changes: 6 additions & 0 deletions packages/odyssey-react-mui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export {
/** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */
Divider,
/** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */
Grid,
KevinGhadyani-Okta marked this conversation as resolved.
Show resolved Hide resolved
/** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */
InputAdornment,
/** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */
InputBase,
Expand All @@ -34,13 +36,16 @@ export {
Paper,
/** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */
ScopedCssBaseline,
/** @deprecated Will be removed in a future Odyssey version in lieu of a wrapped version. */
Stack,
ThemeProvider,
} from "@mui/material";

export type {
CssBaselineProps,
DialogContentTextProps,
DividerProps,
GridProps,
InputAdornmentProps,
InputBaseProps,
ListItemIconProps,
Expand All @@ -49,6 +54,7 @@ export type {
MenuListProps,
PaperProps,
ScopedCssBaselineProps,
StackProps,
ThemeOptions,
} from "@mui/material";

Expand Down
8 changes: 2 additions & 6 deletions packages/odyssey-react-mui/src/labs/datePickerTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ const dateStyles: StateStyles = {
hoverSelected: ({ theme }) => ({
backgroundColor: theme.palette.primary.dark,
color: theme.palette.primary.contrastText,

"@media (pointer: fine)": {
backgroundColor: theme.palette.primary.main,
},
}),
outsideOfMonth: ({ theme }) => ({
backgroundColor: "transparent",
Expand Down Expand Up @@ -158,8 +154,8 @@ export const datePickerTheme: ThemeOptions = {
borderStyle: theme.mixins.borderStyle,
borderWidth: theme.mixins.borderWidth,
borderRadius: theme.mixins.borderRadius,
paddingBlock: theme.spacing(3),
paddingInline: theme.spacing(3),
paddingBlock: theme.spacing(6),
paddingInline: theme.spacing(6),
},
}),
},
Expand Down
3 changes: 2 additions & 1 deletion packages/odyssey-react-mui/src/theme/palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const palette = ({
lighter: odysseyTokens.HueBlue50,
light: odysseyTokens.HueBlue300,
main: odysseyTokens.HueBlue500,
dark: odysseyTokens.HueBlue900,
dark: odysseyTokens.HueBlue700,
darker: odysseyTokens.HueBlue800,
contrastText: odysseyTokens.TypographyColorInverse,
},
secondary: {
Expand Down
2 changes: 2 additions & 0 deletions packages/odyssey-react-mui/src/theme/palette.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@

declare module "@mui/material/styles" {
interface PaletteColor {
darker?: string;
lighter?: string;
}
interface SimplePaletteColorOptions {
darker?: string;
lighter?: string;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export const Multiline: StoryObj<typeof TextField> = {
isMultiline: true,
defaultValue: "",
},
storyName: "Multiline (Textarea)",
name: "Multiline (Textarea)",
};

export const Placeholder: StoryObj<typeof TextField> = {
Expand Down