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: Add UNSAFE documentation to mobile Button and Text #2392

Merged
merged 13 commits into from
Feb 24, 2025
Merged
14 changes: 0 additions & 14 deletions docs/components/Text/Text.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,3 @@ provided.
<Canvas>
<Text size="small">What is this, a font for 🐜s?</Text>
</Canvas>

## Platform Considerations (Mobile)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now in TextNotes.mdx


### Notes

Text uses the core component [Text](https://reactnative.dev/docs/text) from
`react-native`.

### Copying text

There are a few caveats around copying text on Android and iOS that you can read
under the
[Typography](../?path=/docs/components-text-and-typography-typography--docs#platform-considerations)
documentation.
2 changes: 1 addition & 1 deletion packages/components-native/src/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ interface CommonButtonProps {
/**
* **Use at your own risk:** Custom style for specific elements. This should only be used as a
* **last resort**. Using this may result in unexpected side effects.
* More information [here](https://atlantis.getjobber.com/storybook/?path=/docs/guides-customizing-components--docs#unsafe_-props).
* More information in the Customizing components Guide.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

decided to do this instead of:

  • Linking back to Storybook
  • Links don't show up in the prop table on new docs anyway

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would still be valuable to add the link in case the doc is viewed in Storybook.

Suggested change
* More information in the Customizing components Guide.
* More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components).

However, a more general question, should I be seeing UNSAFE_ prop docs on component pages on the new site? Because I don't see them for Button or Text on the new docs site.
image

Copy link
Contributor Author

@taylorvnoj taylorvnoj Feb 24, 2025

Choose a reason for hiding this comment

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

Ok that's fair - I brought the links back in Text and Button (and Popover)

It's strange you don't see the UNSAFE_ props, because they are on prod (since these props were added previous to this PR)
Screenshot 2025-02-24 at 3 02 28 PM

and here it is on local:
Screenshot 2025-02-24 at 3 03 40 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be visible only in "Mobile" tab?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup - since UNSAFE is only in the Text and Button mobile components right now, it'll only be visible in the mobile tab

*/
readonly UNSAFE_style?: ButtonUnsafeStyle;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components-native/src/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface TextProps
/**
* **Use at your own risk:** Custom style for specific elements. This should only be used as a
* **last resort**. Using this may result in unexpected side effects.
* More information [here](https://atlantis.getjobber.com/storybook/?path=/docs/guides-customizing-components--docs#unsafe_-props).
* More information in the Customizing components Guide.
*/
readonly UNSAFE_style?: TypographyUnsafeStyle;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface PopoverProps {
/**
* **Use at your own risk:** Custom class names for specific elements. This should only be used as a
* **last resort**. Using this may result in unexpected side effects.
* More information [here](https://atlantis.getjobber.com/storybook/?path=/docs/guides-customizing-components--docs#unsafe_-props).
* More information in the Customizing components Guide.
Copy link
Contributor

Choose a reason for hiding this comment

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

This line =).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done here 794c005

*/
readonly UNSAFE_className?: {
container?: string;
Expand All @@ -48,7 +48,7 @@ export interface PopoverProps {
/**
* **Use at your own risk:** Custom style for specific elements. This should only be used as a
* **last resort**. Using this may result in unexpected side effects.
* More information [here](https://atlantis.getjobber.com/storybook/?path=/docs/guides-customizing-components--docs#unsafe_-props).
* More information in the Customizing components Guide.
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps, a link here and on line 40?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done here f1c32aa

*/
readonly UNSAFE_style?: {
container?: CSSProperties;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions packages/site/src/content/Button/ButtonNotes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,65 @@ allowed. See

Since this type of `Button` will only be used to submit a form, it does not make
sense to allow the `external`, `onClick`, `to`, or `url` props.

## Component customization

### UNSAFE\_ props (advanced usage)

General information for using `UNSAFE_` props can be found
[here](/guides/customizing-components).

**Note**: Use of `UNSAFE_` props is **at your own risk** and should be
considered a **last resort**. Future Button updates may lead to unintended
breakages.

#### UNSAFE_style (mobile)

The mobile Button component has four elements that can be targeted with styles.
These are the container, content container, icon container, and action label
container.

React Native does not support className. Instead, you can use `UNSAFE_style` to
apply styles either inline or through a StyleSheet.

##### Inline styles

```tsx
UNSAFE_style: {
container: { backgroundColor: tokens["color-purple--light"] },
contentContainer: {
backgroundColor: tokens["color-purple--lighter"],
borderRadius: tokens["radius-large"],
},
iconContainer: { backgroundColor: tokens["color-purple"] },
actionLabelContainer: { paddingLeft: tokens["space-larger"] },
},
```

##### StyleSheet

```tsx
// Button.tsx
UNSAFE_style={{
container: styles.customContainer,
contentContainer: styles.customContentContainer,
iconContainer: styles.customIconContainer,
actionLabelContainer: styles.customActionLabelContainer,
}}

// Button.style.ts
export const styles = StyleSheet.create({
customContainer: {
backgroundColor: tokens["color-purple--light"],
},
customContentContainer: {
borderRadius: tokens["radius-large"],
},
customIconContainer: {
backgroundColor: tokens["color-purple--lighter"],
},
customActionLabelContainer: {
paddingLeft: tokens["space-larger"],
},
});
```
4 changes: 2 additions & 2 deletions packages/site/src/content/Popover/Popover.props.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/site/src/content/Popover/PopoverNotes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### UNSAFE\_ props (advanced usage)

General information for using `UNSAFE_` props can be found
[here](https://atlantis.getjobber.com/storybook/?path=/docs/guides-customizing-components--docs#unsafe_-props).
[here](/guides/customizing-components).

Popover has three elements that can be targeted with classes or styles. These
are the container, the dismiss button container, and the arrow.
Expand Down
2 changes: 1 addition & 1 deletion packages/site/src/content/Text/Text.props-mobile.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions packages/site/src/content/Text/TextNotes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## Component customization

### UNSAFE\_ props (advanced usage)

General information for using `UNSAFE_` props can be found
[here](/guides/customizing-components).

**Note**: Use of `UNSAFE_` props is **at your own risk** and should be
considered a **last resort**. Future Button updates may lead to unintended
breakages.

#### UNSAFE_style (mobile)

The mobile Text component can be custom styled using the `textStyle` type via
the `UNSAFE_style` prop.

React Native does not support className. Instead, you can use `UNSAFE_style` to
apply styles either inline or through a StyleSheet.

##### Inline styles

```tsx
UNSAFE_style={{ textStyle: { color: tokens["color-purple--light"] } }}
```

##### StyleSheet

```tsx
// Text.tsx
UNSAFE_style={{
textStyle: styles.customTextStyle,
}}

// Text.style.ts
export const styles = StyleSheet.create({
customTextStyle: {
color: tokens["color-purple--light"],
},
});
```

## Platform Considerations (Mobile)

### Notes

Text uses the core component [Text](https://reactnative.dev/docs/text) from
`react-native`.

### Copying text

There are a few caveats around copying text on Android and iOS that you can read
under the
[Typography](../?path=/docs/components-text-and-typography-typography--docs#platform-considerations)
documentation.
2 changes: 2 additions & 0 deletions packages/site/src/content/Text/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Content from "@atlantis/docs/components/Text/Text.stories.mdx";
import Props from "./Text.props.json";
import MobileProps from "./Text.props-mobile.json";
import Notes from "./TextNotes.mdx";
import { ContentExport } from "../../types/content";
import { getStorybookUrl } from "../../layout/getStorybookUrl";

Expand All @@ -21,4 +22,5 @@ export default {
),
},
],
notes: () => <Notes />,
} as const satisfies ContentExport;