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

docs(Select/NativeSelect): Update AdditionalContent CodeSandbox examples #1170

Merged
merged 1 commit into from
Dec 6, 2023
Merged
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
5 changes: 5 additions & 0 deletions .changeset/fix-additionalContentDocs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-magma-docs': patch
---

fix(Select/NativeSelect): Update AdditionalContent CodeSandbox examples
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface FormFieldContainerBaseProps {
*/
errorMessage?: React.ReactNode;
/**
* ID of the form field. Also used in the descrption ID.
* ID of the form field. Also used in the description ID.
*/
fieldId: string;
/**
Expand Down
53 changes: 41 additions & 12 deletions website/react-magma-docs/src/pages/api/native-select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { NativeSelect } from 'react-magma-dom';

export function Example() {
return (
<NativeSelect labelText="Select this">
<NativeSelect labelText="Select this" fieldId="example-basic">
<option>Red</option>
<option>Green</option>
<option>Blue</option>
Expand All @@ -47,7 +47,11 @@ export function Example() {
<strong>Changed Value: </strong>{' '}
<span id="changedValue">{message}</span>
</p>
<NativeSelect labelText="Test value" onChange={handleChange}>
<NativeSelect
labelText="Test value"
onChange={handleChange}
fieldId="example-uncontrolled"
>
<option>Choose Color</option>
<option value="Red">Red</option>
<option value="Green">Green</option>
Expand All @@ -65,7 +69,11 @@ import React from 'react';
import { NativeSelect } from 'react-magma-dom';
export function Example() {
return (
<NativeSelect labelText="Test value" value="Green">
<NativeSelect
labelText="Test value"
value="Green"
fieldId="example-controlled"
>
<option>Choose Color</option>
<option value="Red">Red</option>
<option value="Green">Green</option>
Expand All @@ -83,7 +91,7 @@ import { NativeSelect } from 'react-magma-dom';

export function Example() {
return (
<NativeSelect labelText="Select this" disabled>
<NativeSelect labelText="Select this" disabled fieldId="example-disabled">
<option>Red</option>
<option>Green</option>
<option>Blue</option>
Expand All @@ -100,7 +108,11 @@ import { NativeSelect } from 'react-magma-dom';

export function Example() {
return (
<NativeSelect labelText="Select this" errorMessage="This is an error">
<NativeSelect
labelText="Select this"
errorMessage="This is an error"
fieldId="example-error"
>
<option>Red</option>
<option>Green</option>
<option>Blue</option>
Expand All @@ -120,6 +132,7 @@ export function Example() {
<NativeSelect
labelText="Select this"
helperMessage="Helper message appears here"
fieldId="example-helper"
>
<option>Red</option>
<option>Green</option>
Expand All @@ -139,12 +152,16 @@ When `labelPosition` is set to `left`, the label, native select, and child eleme

```tsx
import React from 'react';
import { NativeSelect } from './';
import { LabelPosition } from '../Label';
import { Tooltip } from '../Tooltip';
import { IconButton } from '../IconButton';
import {
NativeSelect,
LabelPosition,
Tooltip,
IconButton,
ButtonSize,
ButtonType,
ButtonVariant,
} from 'react-magma-dom';
import { HelpIcon } from 'react-magma-icons';
import { ButtonSize, ButtonType, ButtonVariant } from '../Button';

export function Example() {
const helpLinkLabel = 'Learn more';
Expand All @@ -156,6 +173,7 @@ export function Example() {
<>
<NativeSelect
labelText="Default positioning"
fieldId="example-additionalContent"
additionalContent={
<Tooltip content={helpLinkLabel}>
<IconButton
Expand Down Expand Up @@ -212,7 +230,11 @@ export function Example() {
return (
<Card isInverse style={{ marginBottom: magma.spaceScale.spacing04 }}>
<CardBody>
<NativeSelect labelText="Select this" isInverse>
<NativeSelect
labelText="Select this"
isInverse
fieldId="example-inverse"
>
<option>Red</option>
<option>Green</option>
<option>Blue</option>
Expand All @@ -233,7 +255,12 @@ export function Example() {
return (
<Card isInverse style={{ marginBottom: magma.spaceScale.spacing04 }}>
<CardBody>
<NativeSelect labelText="Select this" isInverse disabled>
<NativeSelect
labelText="Select this"
isInverse
disabled
fieldId="example-inverseDisabled"
>
<option>Red</option>
<option>Green</option>
<option>Blue</option>
Expand All @@ -258,6 +285,7 @@ export function Example() {
labelText="Select this"
isInverse
errorMessage="This is an error"
fieldId="example-inverseError"
>
<option>Red</option>
<option>Green</option>
Expand All @@ -283,6 +311,7 @@ export function Example() {
labelText="Select this"
isInverse
helperMessage="Helper message appears here"
fieldId="example-inverseHelper"
>
<option>Red</option>
<option>Green</option>
Expand Down
16 changes: 10 additions & 6 deletions website/react-magma-docs/src/pages/api/select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -361,16 +361,20 @@ By default, the child element will display inline with a `Select` label on the r

When `labelPosition` is set to `left`, the label, select, and child elements all display inline.

If no label is required, use `visuallyHidden` and the same inline layout will persist.
If no label is required, use `isLabelVisuallyHidden` and the same inline layout will persist.

```tsx
import React from 'react';
import { Select } from './';
import { LabelPosition } from '../Label';
import { Tooltip } from '../Tooltip';
import { IconButton } from '../IconButton';
import {
Select,
LabelPosition,
Tooltip,
IconButton,
ButtonSize,
ButtonType,
ButtonVariant,
} from 'react-magma-dom';
import { HelpIcon } from 'react-magma-icons';
import { ButtonSize, ButtonType, ButtonVariant } from '../Button';

export function Example() {
const helpLinkLabel = 'Learn more';
Expand Down
Loading