@pyreon/coolgrid 0.11.5 → 0.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -45
- package/lib/index.d.ts +4 -4
- package/lib/index.js +1 -1
- package/package.json +25 -25
- package/src/Col/component.tsx +18 -18
- package/src/Col/index.ts +1 -1
- package/src/Col/styled.ts +12 -12
- package/src/Container/component.tsx +10 -10
- package/src/Container/index.ts +1 -1
- package/src/Container/styled.ts +8 -8
- package/src/Container/utils.ts +2 -2
- package/src/Row/component.tsx +9 -9
- package/src/Row/index.ts +1 -1
- package/src/Row/styled.ts +11 -11
- package/src/__tests__/Col.test.ts +50 -50
- package/src/__tests__/Container.styled.test.ts +21 -21
- package/src/__tests__/Container.test.ts +62 -62
- package/src/__tests__/Row.test.ts +57 -57
- package/src/__tests__/config.test.ts +48 -48
- package/src/__tests__/contextCascading.test.ts +31 -31
- package/src/__tests__/index.test.ts +19 -19
- package/src/__tests__/useContext.test.ts +34 -34
- package/src/__tests__/utils.test.ts +44 -44
- package/src/constants.ts +11 -11
- package/src/context/ContainerContext.ts +2 -2
- package/src/context/RowContext.ts +2 -2
- package/src/context/index.ts +2 -2
- package/src/index.ts +5 -5
- package/src/theme.ts +2 -2
- package/src/types.ts +9 -9
- package/src/useContext.tsx +13 -12
- package/src/utils.ts +2 -2
package/README.md
CHANGED
|
@@ -29,10 +29,7 @@ Provider({
|
|
|
29
29
|
theme,
|
|
30
30
|
children: Container({
|
|
31
31
|
children: Row({
|
|
32
|
-
children: [
|
|
33
|
-
Col({ size: 8, children: 'Main content' }),
|
|
34
|
-
Col({ size: 4, children: 'Sidebar' }),
|
|
35
|
-
],
|
|
32
|
+
children: [Col({ size: 8, children: 'Main content' }), Col({ size: 4, children: 'Sidebar' })],
|
|
36
33
|
}),
|
|
37
34
|
}),
|
|
38
35
|
})
|
|
@@ -54,16 +51,16 @@ Container({
|
|
|
54
51
|
})
|
|
55
52
|
```
|
|
56
53
|
|
|
57
|
-
| Prop
|
|
58
|
-
|
|
|
59
|
-
| columns
|
|
60
|
-
| gap
|
|
61
|
-
| gutter
|
|
62
|
-
| padding
|
|
63
|
-
| width
|
|
64
|
-
| component
|
|
65
|
-
| css
|
|
66
|
-
| contentAlignX | `AlignX`
|
|
54
|
+
| Prop | Type | Description |
|
|
55
|
+
| ------------- | ------------------- | -------------------------------------------- |
|
|
56
|
+
| columns | `number` | Number of grid columns (default: 12) |
|
|
57
|
+
| gap | `number` | Space between columns |
|
|
58
|
+
| gutter | `number` | Outer gutter (negative margin offset on Row) |
|
|
59
|
+
| padding | `number` | Column inner padding |
|
|
60
|
+
| width | `value \| function` | Override container max-width |
|
|
61
|
+
| component | `ComponentFn` | Custom root element |
|
|
62
|
+
| css | `ExtendCss` | Extend container styling |
|
|
63
|
+
| contentAlignX | `AlignX` | Horizontal alignment of columns |
|
|
67
64
|
|
|
68
65
|
All configuration props cascade to Row and Col through context.
|
|
69
66
|
|
|
@@ -75,10 +72,7 @@ Flex wrapper with column management. Inherits Container config and can override
|
|
|
75
72
|
Row({
|
|
76
73
|
size: { xs: 12, md: 6 },
|
|
77
74
|
contentAlignX: 'center',
|
|
78
|
-
children: [
|
|
79
|
-
Col({ children: 'Column 1' }),
|
|
80
|
-
Col({ children: 'Column 2' }),
|
|
81
|
-
],
|
|
75
|
+
children: [Col({ children: 'Column 1' }), Col({ children: 'Column 2' })],
|
|
82
76
|
})
|
|
83
77
|
```
|
|
84
78
|
|
|
@@ -88,19 +82,16 @@ Setting `size` on Row applies it to all Cols inside:
|
|
|
88
82
|
// All columns are 6 of 12
|
|
89
83
|
Row({
|
|
90
84
|
size: 6,
|
|
91
|
-
children: [
|
|
92
|
-
Col({ children: 'Half' }),
|
|
93
|
-
Col({ children: 'Half' }),
|
|
94
|
-
],
|
|
85
|
+
children: [Col({ children: 'Half' }), Col({ children: 'Half' })],
|
|
95
86
|
})
|
|
96
87
|
```
|
|
97
88
|
|
|
98
|
-
| Prop
|
|
99
|
-
|
|
|
100
|
-
| size
|
|
101
|
-
| component
|
|
102
|
-
| css
|
|
103
|
-
| contentAlignX | `AlignX`
|
|
89
|
+
| Prop | Type | Description |
|
|
90
|
+
| ------------- | ------------- | --------------------------------------- |
|
|
91
|
+
| size | `number` | Default column size for all Cols inside |
|
|
92
|
+
| component | `ComponentFn` | Custom row element |
|
|
93
|
+
| css | `ExtendCss` | Extend row styling |
|
|
94
|
+
| contentAlignX | `AlignX` | Override horizontal alignment |
|
|
104
95
|
|
|
105
96
|
### Col
|
|
106
97
|
|
|
@@ -117,12 +108,12 @@ Col({ size: { xs: 12, sm: 6, lg: 4 }, children: 'Responsive' })
|
|
|
117
108
|
Col({ size: { xs: 0, md: 6 }, children: 'Hidden on xs' })
|
|
118
109
|
```
|
|
119
110
|
|
|
120
|
-
| Prop
|
|
121
|
-
|
|
|
122
|
-
| size
|
|
123
|
-
| padding
|
|
124
|
-
| component | `ComponentFn` | Custom column element
|
|
125
|
-
| css
|
|
111
|
+
| Prop | Type | Description |
|
|
112
|
+
| --------- | ------------- | ----------------------------- |
|
|
113
|
+
| size | `number` | Column span (e.g. 4 of 12) |
|
|
114
|
+
| padding | `number` | Override column inner padding |
|
|
115
|
+
| component | `ComponentFn` | Custom column element |
|
|
116
|
+
| css | `ExtendCss` | Extend column styling |
|
|
126
117
|
|
|
127
118
|
## Configuration
|
|
128
119
|
|
|
@@ -139,7 +130,9 @@ Provider({
|
|
|
139
130
|
wide: 1440,
|
|
140
131
|
},
|
|
141
132
|
},
|
|
142
|
-
children: [
|
|
133
|
+
children: [
|
|
134
|
+
/* ... */
|
|
135
|
+
],
|
|
143
136
|
})
|
|
144
137
|
```
|
|
145
138
|
|
|
@@ -149,10 +142,7 @@ Provider({
|
|
|
149
142
|
Container({
|
|
150
143
|
columns: 24,
|
|
151
144
|
children: Row({
|
|
152
|
-
children: [
|
|
153
|
-
Col({ size: 16, children: 'Two thirds' }),
|
|
154
|
-
Col({ size: 8, children: 'One third' }),
|
|
155
|
-
],
|
|
145
|
+
children: [Col({ size: 16, children: 'Two thirds' }), Col({ size: 8, children: 'One third' })],
|
|
156
146
|
}),
|
|
157
147
|
})
|
|
158
148
|
```
|
|
@@ -201,13 +191,13 @@ Col({ size: { xs: 12, md: 6, lg: 4 } })
|
|
|
201
191
|
|
|
202
192
|
## Peer Dependencies
|
|
203
193
|
|
|
204
|
-
| Package
|
|
205
|
-
|
|
|
206
|
-
| @pyreon/core
|
|
194
|
+
| Package | Version |
|
|
195
|
+
| ------------------ | -------- |
|
|
196
|
+
| @pyreon/core | >= 0.0.1 |
|
|
207
197
|
| @pyreon/reactivity | >= 0.0.1 |
|
|
208
|
-
| @pyreon/ui-core
|
|
209
|
-
| @pyreon/unistyle
|
|
210
|
-
| @pyreon/styler
|
|
198
|
+
| @pyreon/ui-core | >= 0.0.1 |
|
|
199
|
+
| @pyreon/unistyle | >= 0.0.1 |
|
|
200
|
+
| @pyreon/styler | >= 0.0.1 |
|
|
211
201
|
|
|
212
202
|
## License
|
|
213
203
|
|
package/lib/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ type Css = Parameters<typeof extendCss>[0];
|
|
|
9
9
|
type ExtraStyles = CreateValueType<Css>;
|
|
10
10
|
type ValueType = CreateValueType<number>;
|
|
11
11
|
type ContainerWidth = CreateValueType<Value>;
|
|
12
|
-
type ContentAlignX =
|
|
12
|
+
type ContentAlignX = 'center' | 'left' | 'right' | 'spaceAround' | 'spaceBetween' | 'spaceEvenly';
|
|
13
13
|
type ConfigurationProps = Partial<{
|
|
14
14
|
size: ValueType;
|
|
15
15
|
padding: ValueType;
|
|
@@ -37,13 +37,13 @@ type ElementType<O extends string[]> = ComponentFn<Omit<ComponentProps, O[number
|
|
|
37
37
|
};
|
|
38
38
|
//#endregion
|
|
39
39
|
//#region src/Col/component.d.ts
|
|
40
|
-
declare const Component: ElementType<[
|
|
40
|
+
declare const Component: ElementType<['containerWidth', 'width', 'rowComponent', 'rowCss', 'colCss', 'colComponent', 'columns', 'gap', 'gutter', 'contentAlignX']>;
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/Container/component.d.ts
|
|
43
|
-
declare const Component$1: ElementType<[
|
|
43
|
+
declare const Component$1: ElementType<['containerWidth']>;
|
|
44
44
|
//#endregion
|
|
45
45
|
//#region src/Row/component.d.ts
|
|
46
|
-
declare const Component$2: ElementType<[
|
|
46
|
+
declare const Component$2: ElementType<['containerWidth', 'width', 'rowComponent', 'rowCss']>;
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/theme.d.ts
|
|
49
49
|
/**
|
package/lib/index.js
CHANGED
|
@@ -48,7 +48,7 @@ const getGridContext = (props = {}, theme = {}) => ({
|
|
|
48
48
|
containerWidth: get(props, "width") || get(theme, "grid.container") || get(theme, "coolgrid.container")
|
|
49
49
|
});
|
|
50
50
|
const useGridContext = (props) => {
|
|
51
|
-
const { theme } = useContext(context);
|
|
51
|
+
const { theme } = useContext(context)();
|
|
52
52
|
const ctxProps = pickThemeProps(props, CONTEXT_KEYS);
|
|
53
53
|
return {
|
|
54
54
|
...getGridContext(ctxProps, theme),
|
package/package.json
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/coolgrid",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.6",
|
|
4
|
+
"description": "Responsive grid system for Pyreon",
|
|
5
|
+
"license": "MIT",
|
|
4
6
|
"repository": {
|
|
5
7
|
"type": "git",
|
|
6
8
|
"url": "https://github.com/pyreon/pyreon",
|
|
7
9
|
"directory": "packages/ui-system/coolgrid"
|
|
8
10
|
},
|
|
9
|
-
"description": "Responsive grid system for Pyreon",
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"type": "module",
|
|
12
|
-
"sideEffects": false,
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"bun": "./src/index.ts",
|
|
16
|
-
"import": "./lib/index.js",
|
|
17
|
-
"types": "./lib/index.d.ts"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"types": "./lib/index.d.ts",
|
|
21
|
-
"main": "./lib/index.js",
|
|
22
11
|
"files": [
|
|
23
12
|
"lib",
|
|
24
13
|
"!lib/**/*.map",
|
|
@@ -27,8 +16,16 @@
|
|
|
27
16
|
"LICENSE",
|
|
28
17
|
"src"
|
|
29
18
|
],
|
|
30
|
-
"
|
|
31
|
-
|
|
19
|
+
"type": "module",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"main": "./lib/index.js",
|
|
22
|
+
"types": "./lib/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"bun": "./src/index.ts",
|
|
26
|
+
"import": "./lib/index.js",
|
|
27
|
+
"types": "./lib/index.d.ts"
|
|
28
|
+
}
|
|
32
29
|
},
|
|
33
30
|
"publishConfig": {
|
|
34
31
|
"access": "public"
|
|
@@ -37,21 +34,24 @@
|
|
|
37
34
|
"prepublish": "bun run build",
|
|
38
35
|
"build": "bun run vl_rolldown_build",
|
|
39
36
|
"build:watch": "bun run vl_rolldown_build-watch",
|
|
40
|
-
"lint": "
|
|
37
|
+
"lint": "oxlint .",
|
|
41
38
|
"test": "vitest run",
|
|
42
39
|
"test:coverage": "vitest run --coverage",
|
|
43
40
|
"test:watch": "vitest",
|
|
44
41
|
"typecheck": "tsc --noEmit"
|
|
45
42
|
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@pyreon/typescript": "^0.11.6",
|
|
45
|
+
"@vitus-labs/tools-rolldown": "^1.15.3"
|
|
46
|
+
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@pyreon/core": "^0.11.
|
|
48
|
-
"@pyreon/reactivity": "^0.11.
|
|
49
|
-
"@pyreon/
|
|
50
|
-
"@pyreon/
|
|
51
|
-
"@pyreon/
|
|
48
|
+
"@pyreon/core": "^0.11.6",
|
|
49
|
+
"@pyreon/reactivity": "^0.11.6",
|
|
50
|
+
"@pyreon/styler": "^0.11.6",
|
|
51
|
+
"@pyreon/ui-core": "^0.11.6",
|
|
52
|
+
"@pyreon/unistyle": "^0.11.6"
|
|
52
53
|
},
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"@pyreon/typescript": "^0.11.5"
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">= 22"
|
|
56
56
|
}
|
|
57
57
|
}
|
package/src/Col/component.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useContext } from
|
|
2
|
-
import { PKG_NAME } from
|
|
3
|
-
import { RowContext } from
|
|
4
|
-
import type { ElementType } from
|
|
5
|
-
import useGridContext from
|
|
6
|
-
import { omitCtxKeys } from
|
|
7
|
-
import Styled from
|
|
1
|
+
import { useContext } from '@pyreon/core'
|
|
2
|
+
import { PKG_NAME } from '../constants'
|
|
3
|
+
import { RowContext } from '../context'
|
|
4
|
+
import type { ElementType } from '../types'
|
|
5
|
+
import useGridContext from '../useContext'
|
|
6
|
+
import { omitCtxKeys } from '../utils'
|
|
7
|
+
import Styled from './styled'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Col (column) component that reads grid settings from RowContext
|
|
@@ -13,20 +13,20 @@ import Styled from "./styled"
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
const DEV_PROPS: Record<string, string> =
|
|
16
|
-
process.env.NODE_ENV !==
|
|
16
|
+
process.env.NODE_ENV !== 'production' ? { 'data-coolgrid': 'col' } : {}
|
|
17
17
|
|
|
18
18
|
const Component: ElementType<
|
|
19
19
|
[
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
'containerWidth',
|
|
21
|
+
'width',
|
|
22
|
+
'rowComponent',
|
|
23
|
+
'rowCss',
|
|
24
|
+
'colCss',
|
|
25
|
+
'colComponent',
|
|
26
|
+
'columns',
|
|
27
|
+
'gap',
|
|
28
|
+
'gutter',
|
|
29
|
+
'contentAlignX',
|
|
30
30
|
]
|
|
31
31
|
> = ({ children, component, css, ...props }) => {
|
|
32
32
|
const parentCtx = useContext(RowContext)
|
package/src/Col/index.ts
CHANGED
package/src/Col/styled.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { config } from
|
|
2
|
-
import type { MakeItResponsiveStyles } from
|
|
3
|
-
import { extendCss, makeItResponsive, value } from
|
|
4
|
-
import type { CssOutput, StyledTypes } from
|
|
5
|
-
import { hasValue, isNumber, isVisible } from
|
|
1
|
+
import { config } from '@pyreon/ui-core'
|
|
2
|
+
import type { MakeItResponsiveStyles } from '@pyreon/unistyle'
|
|
3
|
+
import { extendCss, makeItResponsive, value } from '@pyreon/unistyle'
|
|
4
|
+
import type { CssOutput, StyledTypes } from '../types'
|
|
5
|
+
import { hasValue, isNumber, isVisible } from '../utils'
|
|
6
6
|
|
|
7
7
|
const { styled, css, component } = config
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ type HasWidth = (size?: number, columns?: number) => boolean
|
|
|
12
12
|
const hasWidth: HasWidth = (size, columns) => hasValue(size) && hasValue(columns)
|
|
13
13
|
|
|
14
14
|
type WidthStyles = (
|
|
15
|
-
props: Pick<StyledTypes,
|
|
15
|
+
props: Pick<StyledTypes, 'size' | 'columns' | 'gap'>,
|
|
16
16
|
defaults: { rootSize?: number | undefined },
|
|
17
17
|
) => CssOutput
|
|
18
18
|
|
|
@@ -22,7 +22,7 @@ type WidthStyles = (
|
|
|
22
22
|
*/
|
|
23
23
|
const widthStyles: WidthStyles = ({ size, columns, gap }, { rootSize }) => {
|
|
24
24
|
if (!hasWidth(size, columns)) {
|
|
25
|
-
return
|
|
25
|
+
return ''
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const s = size as number
|
|
@@ -46,11 +46,11 @@ const widthStyles: WidthStyles = ({ size, columns, gap }, { rootSize }) => {
|
|
|
46
46
|
`
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
type SpacingStyles = (type:
|
|
49
|
+
type SpacingStyles = (type: 'margin' | 'padding', param?: number, rootSize?: number) => CssOutput
|
|
50
50
|
/** Applies half of the given value as either margin or padding (used for gap and padding distribution). */
|
|
51
51
|
const spacingStyles: SpacingStyles = (type, param, rootSize) => {
|
|
52
52
|
if (!isNumber(param)) {
|
|
53
|
-
return
|
|
53
|
+
return ''
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const finalStyle = `${type}: ${value((param as number) / 2, rootSize)}`
|
|
@@ -74,8 +74,8 @@ const styles: MakeItResponsiveStyles<StyledTypes> = ({ theme, css: cssFn, rootSi
|
|
|
74
74
|
left: initial;
|
|
75
75
|
position: relative;
|
|
76
76
|
${widthStyles({ size, columns, gap }, { rootSize })};
|
|
77
|
-
${spacingStyles(
|
|
78
|
-
${spacingStyles(
|
|
77
|
+
${spacingStyles('padding', padding, rootSize)};
|
|
78
|
+
${spacingStyles('margin', gap, rootSize)};
|
|
79
79
|
${extendCss(extraStyles)};
|
|
80
80
|
`
|
|
81
81
|
}
|
|
@@ -99,7 +99,7 @@ export default styled(component)`
|
|
|
99
99
|
flex-direction: column;
|
|
100
100
|
|
|
101
101
|
${makeItResponsive({
|
|
102
|
-
key:
|
|
102
|
+
key: '$coolgrid',
|
|
103
103
|
styles,
|
|
104
104
|
css,
|
|
105
105
|
normalize: true,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { provide } from
|
|
2
|
-
import { PKG_NAME } from
|
|
3
|
-
import ContainerContext from
|
|
4
|
-
import type { ElementType } from
|
|
5
|
-
import useGridContext from
|
|
6
|
-
import { omitCtxKeys } from
|
|
7
|
-
import Styled from
|
|
1
|
+
import { provide } from '@pyreon/core'
|
|
2
|
+
import { PKG_NAME } from '../constants'
|
|
3
|
+
import ContainerContext from '../context/ContainerContext'
|
|
4
|
+
import type { ElementType } from '../types'
|
|
5
|
+
import useGridContext from '../useContext'
|
|
6
|
+
import { omitCtxKeys } from '../utils'
|
|
7
|
+
import Styled from './styled'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Container component that establishes the outermost grid boundary.
|
|
@@ -14,9 +14,9 @@ import Styled from "./styled"
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
const DEV_PROPS: Record<string, string> =
|
|
17
|
-
process.env.NODE_ENV !==
|
|
17
|
+
process.env.NODE_ENV !== 'production' ? { 'data-coolgrid': 'container' } : {}
|
|
18
18
|
|
|
19
|
-
const Component: ElementType<[
|
|
19
|
+
const Component: ElementType<['containerWidth']> = ({
|
|
20
20
|
children,
|
|
21
21
|
component,
|
|
22
22
|
css,
|
|
@@ -52,7 +52,7 @@ const Component: ElementType<["containerWidth"]> = ({
|
|
|
52
52
|
|
|
53
53
|
const finalWidth = (() => {
|
|
54
54
|
if (!width) return containerWidth
|
|
55
|
-
if (typeof width ===
|
|
55
|
+
if (typeof width === 'function') return width(containerWidth as Record<string, any>)
|
|
56
56
|
return width
|
|
57
57
|
})()
|
|
58
58
|
|
package/src/Container/index.ts
CHANGED
package/src/Container/styled.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { config } from
|
|
2
|
-
import type { MakeItResponsiveStyles } from
|
|
3
|
-
import { extendCss, makeItResponsive, value } from
|
|
4
|
-
import type { StyledTypes } from
|
|
1
|
+
import { config } from '@pyreon/ui-core'
|
|
2
|
+
import type { MakeItResponsiveStyles } from '@pyreon/unistyle'
|
|
3
|
+
import { extendCss, makeItResponsive, value } from '@pyreon/unistyle'
|
|
4
|
+
import type { StyledTypes } from '../types'
|
|
5
5
|
|
|
6
6
|
const { styled, css, component } = config
|
|
7
7
|
|
|
8
8
|
/** Responsive styles that apply the container's max-width and any extra CSS at each breakpoint. */
|
|
9
|
-
const styles: MakeItResponsiveStyles<Pick<StyledTypes,
|
|
9
|
+
const styles: MakeItResponsiveStyles<Pick<StyledTypes, 'width' | 'extraStyles'>> = ({
|
|
10
10
|
theme: t,
|
|
11
11
|
css: cssFn,
|
|
12
12
|
rootSize,
|
|
13
13
|
}) => {
|
|
14
|
-
const w = t.width != null && typeof t.width !==
|
|
14
|
+
const w = t.width != null && typeof t.width !== 'object' ? t.width : null
|
|
15
15
|
|
|
16
16
|
return cssFn`
|
|
17
|
-
${w != null ? `max-width: ${value(w, rootSize)};` :
|
|
17
|
+
${w != null ? `max-width: ${value(w, rootSize)};` : ''};
|
|
18
18
|
${extendCss(t.extraStyles)};
|
|
19
19
|
`
|
|
20
20
|
}
|
|
@@ -29,7 +29,7 @@ export default styled(component)`
|
|
|
29
29
|
margin-left: auto;
|
|
30
30
|
|
|
31
31
|
${makeItResponsive({
|
|
32
|
-
key:
|
|
32
|
+
key: '$coolgrid',
|
|
33
33
|
styles,
|
|
34
34
|
css,
|
|
35
35
|
normalize: true,
|
package/src/Container/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from
|
|
1
|
+
import { get } from '@pyreon/ui-core'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Resolves the container max-width map using a three-layer fallback:
|
|
@@ -10,4 +10,4 @@ type GetContainerWidth = (
|
|
|
10
10
|
) => ReturnType<typeof get>
|
|
11
11
|
|
|
12
12
|
export const getContainerWidth: GetContainerWidth = (props, theme) =>
|
|
13
|
-
get(props,
|
|
13
|
+
get(props, 'width') || get(theme, 'grid.container') || get(theme, 'coolgrid.container')
|
package/src/Row/component.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { provide, useContext } from
|
|
2
|
-
import { PKG_NAME } from
|
|
3
|
-
import { ContainerContext, RowContext } from
|
|
4
|
-
import type { ElementType } from
|
|
5
|
-
import useGridContext from
|
|
6
|
-
import { omitCtxKeys } from
|
|
7
|
-
import Styled from
|
|
1
|
+
import { provide, useContext } from '@pyreon/core'
|
|
2
|
+
import { PKG_NAME } from '../constants'
|
|
3
|
+
import { ContainerContext, RowContext } from '../context'
|
|
4
|
+
import type { ElementType } from '../types'
|
|
5
|
+
import useGridContext from '../useContext'
|
|
6
|
+
import { omitCtxKeys } from '../utils'
|
|
7
|
+
import Styled from './styled'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Row component that reads inherited config from ContainerContext, merges
|
|
@@ -14,9 +14,9 @@ import Styled from "./styled"
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
const DEV_PROPS: Record<string, string> =
|
|
17
|
-
process.env.NODE_ENV !==
|
|
17
|
+
process.env.NODE_ENV !== 'production' ? { 'data-coolgrid': 'row' } : {}
|
|
18
18
|
|
|
19
|
-
const Component: ElementType<[
|
|
19
|
+
const Component: ElementType<['containerWidth', 'width', 'rowComponent', 'rowCss']> = ({
|
|
20
20
|
children,
|
|
21
21
|
component,
|
|
22
22
|
css,
|
package/src/Row/index.ts
CHANGED
package/src/Row/styled.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { config } from
|
|
2
|
-
import type { MakeItResponsiveStyles } from
|
|
3
|
-
import { ALIGN_CONTENT_MAP_X, extendCss, makeItResponsive, value } from
|
|
4
|
-
import type { CssOutput, StyledTypes } from
|
|
5
|
-
import { isNumber } from
|
|
1
|
+
import { config } from '@pyreon/ui-core'
|
|
2
|
+
import type { MakeItResponsiveStyles } from '@pyreon/unistyle'
|
|
3
|
+
import { ALIGN_CONTENT_MAP_X, extendCss, makeItResponsive, value } from '@pyreon/unistyle'
|
|
4
|
+
import type { CssOutput, StyledTypes } from '../types'
|
|
5
|
+
import { isNumber } from '../utils'
|
|
6
6
|
|
|
7
7
|
const { styled, css, component } = config
|
|
8
8
|
|
|
@@ -13,12 +13,12 @@ const { styled, css, component } = config
|
|
|
13
13
|
* at the row edges.
|
|
14
14
|
*/
|
|
15
15
|
type SpacingStyles = (
|
|
16
|
-
props: Pick<StyledTypes,
|
|
16
|
+
props: Pick<StyledTypes, 'gap' | 'gutter'>,
|
|
17
17
|
{ rootSize }: { rootSize?: number | undefined },
|
|
18
18
|
) => CssOutput
|
|
19
19
|
|
|
20
20
|
const spacingStyles: SpacingStyles = ({ gap, gutter }, { rootSize }) => {
|
|
21
|
-
if (!isNumber(gap)) return
|
|
21
|
+
if (!isNumber(gap)) return ''
|
|
22
22
|
|
|
23
23
|
const g = gap as number
|
|
24
24
|
const getValue = (param: string | number | null | undefined) => value(param, rootSize)
|
|
@@ -32,8 +32,8 @@ const spacingStyles: SpacingStyles = ({ gap, gutter }, { rootSize }) => {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/** Maps the contentAlignX prop to a CSS justify-content value. */
|
|
35
|
-
const contentAlign = (align?: StyledTypes[
|
|
36
|
-
if (!align) return
|
|
35
|
+
const contentAlign = (align?: StyledTypes['contentAlignX']) => {
|
|
36
|
+
if (!align) return ''
|
|
37
37
|
|
|
38
38
|
return css`
|
|
39
39
|
justify-content: ${ALIGN_CONTENT_MAP_X[align]};
|
|
@@ -42,7 +42,7 @@ const contentAlign = (align?: StyledTypes["contentAlignX"]) => {
|
|
|
42
42
|
|
|
43
43
|
/** Composes spacing, alignment, and extra CSS into a single responsive style block for the Row. */
|
|
44
44
|
const styles: MakeItResponsiveStyles<
|
|
45
|
-
Pick<StyledTypes,
|
|
45
|
+
Pick<StyledTypes, 'gap' | 'gutter' | 'contentAlignX' | 'extraStyles'>
|
|
46
46
|
> = ({ theme, css: cssFn, rootSize }) => {
|
|
47
47
|
const { gap, gutter, contentAlignX, extraStyles } = theme
|
|
48
48
|
|
|
@@ -62,7 +62,7 @@ export default styled(component)`
|
|
|
62
62
|
flex-direction: row;
|
|
63
63
|
|
|
64
64
|
${makeItResponsive({
|
|
65
|
-
key:
|
|
65
|
+
key: '$coolgrid',
|
|
66
66
|
styles,
|
|
67
67
|
css,
|
|
68
68
|
normalize: true,
|