-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Update the
MarigoldProvider
page (#4180)
* almost * marigold provider resisted * Create tidy-needles-sort.md * Update provider.mdx * update * added <>
- Loading branch information
Showing
3 changed files
with
63 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@marigold/docs": patch | ||
--- | ||
|
||
docs: Update the `MarigoldProvider` page | ||
|
||
Updated the MarigoldProvider page according to our new page layout and information. |
12 changes: 12 additions & 0 deletions
12
docs/content/components/application/provider/provider-root-styles.demo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Card, Inset, MarigoldProvider } from '@marigold/components'; | ||
import theme from '@marigold/theme-core'; | ||
|
||
export default () => ( | ||
<MarigoldProvider theme={theme} className="bg-bg-surface-sunken rounded-lg"> | ||
<Inset space={6}> | ||
<Card p={4}> | ||
This card will always be on a sunken surface with rounded corners. | ||
</Card> | ||
</Inset> | ||
</MarigoldProvider> | ||
); |
65 changes: 44 additions & 21 deletions
65
docs/content/components/application/provider/provider.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,65 @@ | ||
--- | ||
title: MarigoldProvider | ||
caption: Provider which applies the theme. | ||
caption: Container for apps using Marigold. | ||
--- | ||
|
||
`<MarigoldProvider>` is the container for all Marigold applications. It defines the theme and other application level settings. | ||
Without the `<MarigoldProvider>` you can't get the theme on your components. So it is necessary to use. | ||
The `<MarigoldProvider>` component serves as the wrapper for any application that integrates with Marigold. It is responsible for managing and distributing critical application-level settings, including providing theming to all child components. | ||
|
||
You just have to wrap your components around the `<MarigoldProvider>` to make it work. | ||
If you want to get more information about the setup go to [Getting Started](/getting-started/installation/#bootstrapping). | ||
By wrapping an app in `<MarigoldProvider>`, developers can ensure that a consistent theme and other globally relevant configurations are propagated throughout the app's component tree. | ||
|
||
```tsx | ||
import { Button, MarigoldProvider } from '@marigold/components'; | ||
## Appearance | ||
|
||
<MarigoldProvider theme={theme}> | ||
<Button variant="primary">Hello World!</Button> | ||
</MarigoldProvider>; | ||
``` | ||
The `<MarigoldProvider>` component does not have its own visual appearance. However, it hosts the root styles of a theme, ensuring that global styles and theming are applied across the entire app. | ||
|
||
## Usage | ||
|
||
### Setup | ||
|
||
## Import | ||
It is recommended to place `<MarigoldProvider>` in its own file, alongside other providers you may use, and wrap your root component with it. This approach keeps your project structure organized and ensures that global settings like theming are applied consistently across your app. | ||
|
||
```tsx | ||
import { PropsWithChildren } from 'react'; | ||
import { MarigoldProvider } from '@marigold/components'; | ||
import theme from '@marigold/theme-core'; | ||
|
||
export const App = ({ children }: PropsWithChildren) => ( | ||
<MarigoldProvider theme={theme}>{children}</MarigoldProvider> | ||
); | ||
``` | ||
|
||
## Props | ||
### Overriding root styles | ||
|
||
<PropsTable component={title} /> | ||
The `<MarigoldProvider>` supports overriding root styles by passing custom class names to it. This feature is useful when you need to adjust or customize the root styles, depending on the context in which your app is used. | ||
|
||
## Examples | ||
<ComponentDemo file="./provider-root-styles.demo.tsx" /> | ||
|
||
### Provider with Button | ||
### Nesting Providers | ||
|
||
The example shows how the `<MarigoldProvider>` works. As simple as it is you just have to wrap the component around the provider and import a theme. You can click on the theme select on top of the page to see how the `<Button>` changes its theme. | ||
The `<MarigoldProvider>` supports nesting themes, allowing you to apply a different theme within a nested provider. This enables sections of your app to have distinct themes, providing flexibility in styling different parts of the application. | ||
|
||
Note that in these scenarios, it often makes sense to adjust the root styles using the aforementioned `className` prop. | ||
|
||
```tsx | ||
import { Button, MarigoldProvider } from '@marigold/components'; | ||
import { Card, MarigoldProvider, Stack } from '@marigold/components'; | ||
import core from '@marigold/theme-core'; | ||
import b2b from '@marigold/theme-core'; | ||
|
||
<MarigoldProvider theme={theme}> | ||
<Button variant="primary">Hello World!</Button> | ||
</MarigoldProvider>; | ||
export default () => ( | ||
<MarigoldProvider theme={core}> | ||
<Card p={4}> | ||
<Stack space={4}> | ||
This area is still using the <strong>core theme</strong>. | ||
<MarigoldProvider theme={b2b} className="bg-transparent"> | ||
This area is still using the <strong>b2b theme</strong>. | ||
</MarigoldProvider> | ||
</Stack> | ||
</Card> | ||
</MarigoldProvider> | ||
); | ||
``` | ||
|
||
## Props | ||
|
||
<StorybookHintMessage component={title} /> | ||
|
||
<PropsTable component={title} /> |