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

FIxes > Various Docs site issues #1574

Merged
merged 13 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions .changeset/fix-docs-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-magma-docs': patch
---

fix(Docs): Within the Docs site, these components have had fixes for missing references and general clean-up for CodeSandbox examples: Grid, Container, Stepper, Combobox, Hyperlink, IconButton, Toast, DatePicker, Dropdown, Form, FormGroup, useFocusLock
36 changes: 19 additions & 17 deletions website/react-magma-docs/src/pages/api/combobox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -637,18 +637,18 @@ export function Example() {
## Async

```tsx
import React from 'react';
import { Combobox } from 'react-magma-dom';
import React from "react";
import { Combobox } from "react-magma-dom";

export function Example() {
const [isLoading, updateIsLoading] = React.useState<boolean>(false);

function loadItems(inputValue) {
return new Promise(resolve =>
function loadItems() {
return new Promise((resolve) =>
resolve([
{ label: 'Yellow', value: 'yellow' },
{ label: 'Pink', value: 'pink' },
{ label: 'Periwinkle', value: 'periwinkle' },
{ label: "Yellow", value: "yellow" },
{ label: "Pink", value: "pink" },
{ label: "Periwinkle", value: "periwinkle" },
])
);
}
Expand All @@ -662,9 +662,9 @@ export function Example() {

setTimeout(() => {
updateIsLoading(false);
loadItems(inputValue).then(items => {
loadItems().then((items: any) => {
setInputItems(
items.filter(item =>
items.filter((item) =>
item.label.toLowerCase().startsWith(inputValue.toLowerCase())
)
);
Expand All @@ -678,9 +678,9 @@ export function Example() {
labelText="Async"
isLoading={isLoading}
defaultItems={[
{ label: 'Red', value: 'red' },
{ label: 'Blue', value: 'blue' },
{ label: 'Green', value: 'green' },
{ label: "Red", value: "red" },
{ label: "Blue", value: "blue" },
{ label: "Green", value: "green" },
]}
onInputValueChange={handleInputValueChange}
/>
Expand Down Expand Up @@ -944,7 +944,7 @@ import { Combobox, LabelPosition } from 'react-magma-dom';
export function Example() {
return (
<Combobox
labelPosition={LabelPosition.top}
labelPosition={LabelPosition.left}
labelText="Left-aligned label"
defaultItems={[
{ label: 'Red', value: 'red' },
Expand Down Expand Up @@ -1021,6 +1021,7 @@ custom `type`](/api/combobox#custom_items_typescript).
```tsx
import React from 'react';
import { Combobox } from 'react-magma-dom';
import { v4 as uuidv4 } from "uuid";

export function Example() {
const [controlledSelectedItem, updateControlledSelectedItem] =
Expand All @@ -1041,7 +1042,7 @@ export function Example() {
const { value } = item;

return {
id: uuid(),
id: uuidv4(),
name: value,
representation: value.charAt(0).toUpperCase() + value.slice(1),
};
Expand Down Expand Up @@ -1100,6 +1101,7 @@ element with the shape of the `items` you are passing in.
```tsx
import React from 'react';
import { Combobox } from 'react-magma-dom';
import { v4 as uuidv4 } from "uuid";

interface CustomComboboxItem {
id: number;
Expand Down Expand Up @@ -1141,7 +1143,7 @@ export function Example() {
const { value } = item;

return {
id: uuid(),
id: uuidv4(),
name: value,
representation: value.charAt(0).toUpperCase() + value.slice(1),
};
Expand Down Expand Up @@ -1272,7 +1274,7 @@ import { Combobox } from 'react-magma-dom';
export function Example() {
const [isLoading, updateIsLoading] = React.useState<boolean>(false);

function loadItems(inputValue) {
function loadItems() {
return new Promise(resolve =>
resolve([
{ label: 'Yellow', value: 'yellow' },
Expand All @@ -1291,7 +1293,7 @@ export function Example() {

setTimeout(() => {
updateIsLoading(false);
loadItems(inputValue).then(items => {
loadItems().then((items: any) => {
setInputItems(
items.filter(item =>
item.label.toLowerCase().startsWith(inputValue.toLowerCase())
Expand Down
8 changes: 4 additions & 4 deletions website/react-magma-docs/src/pages/api/container.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Container, Heading, Hyperlink, Paragraph } from 'react-magma-dom';
export function Example() {
return (
<Container>
<Heading level="3">Basic Container</Heading>
<Heading level={3}>Basic Container</Heading>
<Paragraph>
Paragraph with <Hyperlink to="#">hyperlink</Hyperlink>
</Paragraph>
Expand All @@ -43,7 +43,7 @@ import { Container, Heading, Paragraph, Hyperlink } from 'react-magma-dom';
export function Example() {
return (
<Container isInverse>
<Heading level="3">Basic Container</Heading>
<Heading level={3}>Basic Container</Heading>
<Paragraph>
Paragraph with <Hyperlink to="#">hyperlink</Hyperlink>
</Paragraph>
Expand All @@ -63,7 +63,7 @@ import { Container, Heading, Paragraph, Hyperlink } from 'react-magma-dom';
export function Example() {
return (
<Container isInverse maxWidth={600}>
<Heading level="3">Basic Container</Heading>
<Heading level={3}>Basic Container</Heading>
<Paragraph>
Paragraph with <Hyperlink to="#">hyperlink</Hyperlink>
</Paragraph>
Expand All @@ -83,7 +83,7 @@ import { Container, Heading, Paragraph, Hyperlink } from 'react-magma-dom';
export function Example() {
return (
<Container isInverse gutterWidth={80}>
<Heading level="3">Basic Container</Heading>
<Heading level={3}>Basic Container</Heading>
<Paragraph>
Paragraph with <Hyperlink to="#">hyperlink</Hyperlink>
</Paragraph>
Expand Down
8 changes: 4 additions & 4 deletions website/react-magma-docs/src/pages/api/date-pickers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import React from 'react';
import { DatePicker } from 'react-magma-dom';

export function Example() {
return <DatePicker defaultDate="07/23/2024" labelText="Date" />;
return <DatePicker defaultDate={new Date(2025, 1, 0)} labelText="Date" />;
}
```

Expand All @@ -48,7 +48,7 @@ import { DatePicker } from 'react-magma-dom';

export function Example() {
return (
<DatePicker defaultDate="07/23/2024" labelText="Date" value="03/12/2024" />
<DatePicker defaultDate={new Date(2025, 1, 0)} labelText="Date" value="03/12/2024" />
);
}
```
Expand Down Expand Up @@ -187,7 +187,7 @@ export function Example() {

```tsx
import React from 'react';
import { DatePicker, Card, CardBody, magma } from 'react-magma-dom';
import { DatePicker, Card, CardBody } from 'react-magma-dom';

export function Example() {
return (
Expand Down Expand Up @@ -352,7 +352,7 @@ export function Example() {

## Keyboard Navigation

The `DatePicker` is keyboard navigable for allowing the user to navigate between days, weeks, and months. If you would like to see all of the options for keyboard navigation click on the `?` button in the bottom right corner of the `DatePicker` or press the `?` key.
The `DatePicker` is keyboard navigable for allowing the user to navigate between days, weeks, and months.

```tsx
import React from 'react';
Expand Down
35 changes: 22 additions & 13 deletions website/react-magma-docs/src/pages/api/dropdown.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function Example() {

return (
<Dropdown>
<DropdownSplitButton onClick={handleSplitButtonClick}>
<DropdownSplitButton aria-label="Split Button" onClick={handleSplitButtonClick}>
Split Button
</DropdownSplitButton>
<DropdownContent>
Expand Down Expand Up @@ -465,7 +465,7 @@ export function Example() {
<Dropdown width={240}>
<DropdownButton>Expandable Items Dropdown</DropdownButton>
<DropdownContent>
<DropdownExpandableMenuGroup defaultIndex={[0]}>
<DropdownExpandableMenuGroup isMulti defaultIndex={[0]}>
<DropdownExpandableMenuItem>
<DropdownExpandableMenuButton icon={<RestaurantMenuIcon />}>
Pasta
Expand Down Expand Up @@ -566,33 +566,37 @@ that returns a `DropdownMenuItem`.
For a custom component you'll receive a `dropdownMenuItemProps` prop that you must spread in to the `DropdownMenuItem` component in your renderer.

```tsx
import React from 'react';
import React from "react";
import {
Dropdown,
DropdownButton,
DropdownContent,
DropdownMenuItem,
} from 'react-magma-dom';
} from "react-magma-dom";

export function Example() {
const OptionalDropdownMenuItem = ({ toggle, dropdownMenuItemProps }) => {
const showItem2 = true;

const OptionalDropdownMenuItem = ({
toggle,
children,
dropdownMenuItemProps,
}) => {
return toggle ? (
<DropdownMenuItem {...dropdownMenuItemProps}>
Hello There
</DropdownMenuItem>
<DropdownMenuItem {...dropdownMenuItemProps}>{children}</DropdownMenuItem>
) : null;
};

function handleMenuItem1Click() {
alert('Item 1 clicked');
alert("Item 1 clicked");
}

function handleMenuItem2Click() {
alert('Item 2 clicked');
alert("Item 2 clicked");
}

function handleMenuItem3Click() {
alert('Item 3 clicked');
alert("Item 3 clicked");
}

return (
Expand All @@ -602,8 +606,11 @@ export function Example() {
<DropdownMenuItem onClick={handleMenuItem1Click}>
Menu item 1
</DropdownMenuItem>
<OptionalDropdownMenuItem toggle onClick={handleMenuItem2Click}>
Menu item 2
<OptionalDropdownMenuItem
toggle={showItem2}
onClick={handleMenuItem2Click}
>
Menu item 2 (optional)
</OptionalDropdownMenuItem>
<div>
<DropdownMenuItem onClick={handleMenuItem3Click}>
Expand All @@ -614,6 +621,7 @@ export function Example() {
</Dropdown>
);
}

```

### Leading Icons
Expand Down Expand Up @@ -752,6 +760,7 @@ import {
ButtonColor,
ButtonSize,
ButtonGroup,
ButtonVariant,
Dropdown,
DropdownButton,
DropdownContent,
Expand Down
2 changes: 1 addition & 1 deletion website/react-magma-docs/src/pages/api/form.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function Example() {
}
```

# Form Props
## Form Props

**Any other props supplied will be provided to the wrapping `form` element.**

Expand Down
5 changes: 1 addition & 4 deletions website/react-magma-docs/src/pages/api/formgroup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ export function Example() {
Labelled by <i>label</i>
</>
}
name="labelledByGroup"
>
<Checkbox labelText="Label" />
<Checkbox labelText="Label" />
</FormGroup>
<FormGroup labelledById="h3Label" name="labelledByGroup">
<FormGroup labelledById="h3Label" >
<Heading id="h3Label" level={3}>
Labelled by H3
</Heading>
Expand All @@ -100,7 +99,6 @@ export function Example() {
containerStyle={{ border: '1px solid gray', padding: '10px' }}
labelStyle={{ fontWeight: '500', color: 'red' }}
labelText="Group label"
name="labelledByGroup"
>
<Checkbox labelText="Checkbox label" />
<Checkbox labelText="Checkbox label" />
Expand All @@ -121,7 +119,6 @@ export function Example() {
return (
<FormGroup
labelText="Group Label"
name="labelledByGroup"
isTextVisuallyHidden
>
<Checkbox labelText="Checkbox label" />
Expand Down
7 changes: 3 additions & 4 deletions website/react-magma-docs/src/pages/api/grid.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Child elements can be added as they are, or inside of `<GridItem></GridItem>`. `

```typescript
import React from 'react';
import styled from '@emotion/styled';
import {
Grid,
GridItem,
Expand Down Expand Up @@ -148,15 +147,15 @@ export function Example() {

```typescript
import React from 'react';
import { Grid, GridItem } from 'react-magma-dom';
import { Grid, GridItem, gridAlignItems, GridJustifyContent } from 'react-magma-dom';

export function Example() {
return (
<Grid
gridTemplateColumns="repeat(4, 1fr)"
gridGap="1em"
gridJustifyContent="center"
gridAlignItems="center"
gridJustifyContent={GridJustifyContent.center}
gridAlignItems={GridAlignItems.center}
>
<GridItem
gridRow="1 / 4"
Expand Down
10 changes: 6 additions & 4 deletions website/react-magma-docs/src/pages/api/hyperlink.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,21 @@ import React from 'react';
import {
Hyperlink,
HyperlinkIconPosition,
magma,
Spacer,
SpacerAxis,
ButtonTextTransform,
Paragraph,
Flex,
FlexBehavior,
FlexJustify,
} from 'react-magma-dom';
TypographyVisualStyle,
} from "react-magma-dom";
import {
KeyboardArrowLeftIcon,
KeyboardArrowRightIcon,
CalendarTodayIcon,
OpenInNewIcon
} from 'react-magma-icons';
OpenInNewIcon,
} from "react-magma-icons";

export function Example() {
return (
Expand Down
Loading
Loading