Skip to content

Commit 0d894cb

Browse files
committed
feat: merge providers
1 parent 8074814 commit 0d894cb

16 files changed

Lines changed: 124 additions & 204 deletions

docs/Contributing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: Contributing
3-
order: 100
3+
order: 80
44
route: '/contributing'
55
---
66

docs/Customization.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import { ThemeProvider } from 'paramount-ui'
1717
colors: Colors;
1818
fills: Fills;
1919
20+
// Layout
21+
layout: Layout;
22+
2023
// Typography
2124
fontFamilies: FontFamilies;
2225
fontWeights: FontWeights;
@@ -495,9 +498,33 @@ const containerShapes: ContainerShapes = {
495498
},
496499
};
497500
501+
export const defaultLayout: Layout = {
502+
breakpoints: {
503+
small: 480,
504+
505+
medium: 768,
506+
507+
large: 992,
508+
509+
xlarge: 1200,
510+
},
511+
containerSizes: {
512+
small: 540,
513+
514+
medium: 720,
515+
516+
large: 960,
517+
518+
xlarge: 1140,
519+
},
520+
gridColumnCount: 12,
521+
gutterWidth: 30,
522+
};
523+
498524
export const defaultTheme: Theme = {
499525
colors,
500526
fills,
527+
layout,
501528
502529
fontFamilies,
503530
fontWeights,

docs/GettingStarted.mdx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,9 @@ On top of your application, include context providers
3333

3434
```tsx
3535
import React from 'react';
36-
import { ThemeProvider, ToastProvider, LayoutProvider } from 'paramount-ui';
37-
38-
const App = () => (
39-
<ThemeProvider>
40-
<ToastProvider>
41-
<LayoutProvider>{children}</LayoutProvider>
42-
</ToastProvider>
43-
</ThemeProvider>
44-
);
36+
import { ThemeProvider } from 'paramount-ui';
37+
38+
const App = () => <ThemeProvider>{children}</ThemeProvider>;
4539

4640
export default App;
4741
```
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
---
22
name: Layout
3-
menu: Components
3+
order: 85
44
---
55

66
import { Playground, Props } from 'docz';
7-
import { LayoutProvider, useLayout, Text } from '..';
7+
import { ThemeProvider, useLayout, Text } from '../src';
88

9-
export default ({ children }) => <LayoutProvider>{children}</LayoutProvider>;
9+
export default ({ children }) => <ThemeProvider>{children}</ThemeProvider>;
1010

1111
# Layout
1212

1313
Paramount provides building blocks to create responsive layout via components `Visible`, `Row and Column`, `Container` and convenience functions ([see Usage](#usage))
1414

1515
## Setup
1616

17-
Put `LayoutProvider` at the top level component to wrap components that make use of `LayoutContext`. For options, [see Configuration Options](#options)
17+
Make sure to use `ThemeProvider` at the top-level component. For options, [see Configuration Options](#options)
1818

1919
```tsx
20-
<LayoutProvider value={options}>{children}</LayoutProvider>
20+
<ThemeProvider value={{ layout: options }}>{children}</ThemeProvider>
2121
```
2222

2323
## Usage
@@ -69,7 +69,7 @@ Retrieves the current screen size
6969
These are all the available configuration options, as well as the default layout configuration
7070

7171
```ts
72-
export const defaultLayout: LayoutInterface = {
72+
export const defaultLayout: Layout = {
7373
breakpoints: {
7474
small: 480,
7575

src/components/KitchenSink/KitchenSink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ export const KitchenSink = () => {
10151015
notify({
10161016
title: 'Title',
10171017
description: 'Description',
1018-
duration: 100000,
1018+
duration: 5000,
10191019
})
10201020
}
10211021
title="Open toast"

src/components/Layout/Column.styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { Theme } from '../../theme/Theme';
44
import { ColumnConfig, ColumnConfigBase, ColumnProps } from './Column';
55
import {
66
DESC_ORDER_SCREEN_SIZES,
7-
LayoutInterface,
7+
LayoutContext,
88
ScreenSize,
99
} from './LayoutContext';
1010

1111
export type GetColumnStyles = (
12-
props: ColumnProps & LayoutInterface,
12+
props: ColumnProps & LayoutContext,
1313
theme: Theme,
1414
) => Partial<ColumnStyles>;
1515

src/components/Layout/Container.styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { ContainerProps } from './Container';
55
import {
66
ContainerSizes,
77
DESC_ORDER_SCREEN_SIZES,
8-
LayoutInterface,
8+
LayoutContext,
99
ScreenSize,
1010
} from './LayoutContext';
1111

1212
export type GetContainerStyles = (
13-
props: ContainerProps & LayoutInterface,
13+
props: ContainerProps & LayoutContext,
1414
theme: Theme,
1515
) => Partial<ContainerStyles>;
1616

src/components/Layout/LayoutContext.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,19 @@ export type GetResponsiveValue = <
8585
| TXsmallValue
8686
| undefined;
8787

88-
export interface LayoutInterface {
88+
export interface Layout {
8989
breakpoints: Breakpoints;
90-
currentScreenSize: ScreenSize;
91-
getResponsiveValue: GetResponsiveValue;
9290
gridColumnCount: ColumnCount;
9391
gutterWidth: number;
9492
containerSizes: ContainerSizes;
9593
}
9694

97-
export const defaultLayout: LayoutInterface = {
95+
export interface LayoutContext extends Layout {
96+
currentScreenSize: ScreenSize;
97+
getResponsiveValue: GetResponsiveValue;
98+
}
99+
100+
export const defaultLayout: LayoutContext = {
98101
breakpoints: {
99102
small: 480,
100103

src/components/Layout/LayoutProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import {
66
defaultLayout,
77
DESC_ORDER_SCREEN_SIZES,
88
GetResponsiveValueParam,
9+
Layout,
910
LayoutContext,
10-
LayoutInterface,
1111
ScreenSize,
1212
} from './LayoutContext';
1313

1414
export interface LayoutProviderProps {
1515
children: React.ReactNode;
16-
value?: Partial<LayoutInterface>;
16+
value?: Partial<Layout>;
1717
}
1818

19-
export const getCurrentScreenSize = (layout: LayoutInterface) => {
19+
export const getCurrentScreenSize = (layout: Layout) => {
2020
const { breakpoints } = layout;
2121
const windowScaledSize = Dimensions.get('window');
2222

src/components/Layout/Row.styles.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { ViewStyle } from 'react-native';
22

33
import { Theme } from '../../theme/Theme';
4-
import { LayoutInterface } from './LayoutContext';
4+
import { LayoutContext } from './LayoutContext';
55
import { RowProps } from './Row';
66

77
export type GetRowStyles = (
8-
props: RowProps & LayoutInterface,
8+
props: RowProps & LayoutContext,
99
theme: Theme,
1010
) => Partial<RowStyles>;
1111

0 commit comments

Comments
 (0)