@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/src/constants.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const PKG_NAME =
|
|
1
|
+
export const PKG_NAME = '@pyreon/coolgrid'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Grid configuration keys that are passed through context
|
|
@@ -7,14 +7,14 @@ export const PKG_NAME = "@pyreon/coolgrid"
|
|
|
7
7
|
export const CONTEXT_KEYS = [
|
|
8
8
|
// 'breakpoints',
|
|
9
9
|
// 'rootSize',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
'columns',
|
|
11
|
+
'size',
|
|
12
|
+
'gap',
|
|
13
|
+
'padding',
|
|
14
|
+
'gutter',
|
|
15
|
+
'colCss',
|
|
16
|
+
'colComponent',
|
|
17
|
+
'rowCss',
|
|
18
|
+
'rowComponent',
|
|
19
|
+
'contentAlignX',
|
|
20
20
|
]
|
package/src/context/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Provider } from
|
|
2
|
-
import Col from
|
|
3
|
-
import Container from
|
|
4
|
-
import Row from
|
|
5
|
-
import theme from
|
|
1
|
+
import { Provider } from '@pyreon/unistyle'
|
|
2
|
+
import Col from './Col'
|
|
3
|
+
import Container from './Container'
|
|
4
|
+
import Row from './Row'
|
|
5
|
+
import theme from './theme'
|
|
6
6
|
|
|
7
7
|
export { Col, Container, Provider, Row, theme }
|
package/src/theme.ts
CHANGED
|
@@ -14,7 +14,7 @@ export default {
|
|
|
14
14
|
grid: {
|
|
15
15
|
columns: 12,
|
|
16
16
|
container: {
|
|
17
|
-
xs:
|
|
17
|
+
xs: '100%',
|
|
18
18
|
sm: 540,
|
|
19
19
|
md: 720,
|
|
20
20
|
lg: 960,
|
|
@@ -32,7 +32,7 @@ export const defaultBreakpoints: Record<string, number> = {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export const defaultContainerWidths: Record<string, string | number> = {
|
|
35
|
-
xs:
|
|
35
|
+
xs: '100%',
|
|
36
36
|
sm: 540,
|
|
37
37
|
md: 720,
|
|
38
38
|
lg: 960,
|
package/src/types.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* and the resolved styled-component prop types.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { ComponentFn, VNodeChild } from
|
|
9
|
-
import type { BreakpointKeys, config } from
|
|
10
|
-
import type { AlignContentAlignXKeys, extendCss } from
|
|
8
|
+
import type { ComponentFn, VNodeChild } from '@pyreon/core'
|
|
9
|
+
import type { BreakpointKeys, config } from '@pyreon/ui-core'
|
|
10
|
+
import type { AlignContentAlignXKeys, extendCss } from '@pyreon/unistyle'
|
|
11
11
|
|
|
12
12
|
type CreateValueType<T> = T | T[] | Partial<Record<BreakpointKeys, T>>
|
|
13
13
|
|
|
@@ -22,12 +22,12 @@ export type ValueType = CreateValueType<number>
|
|
|
22
22
|
export type ContainerWidth = CreateValueType<Value>
|
|
23
23
|
|
|
24
24
|
export type ContentAlignX =
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
25
|
+
| 'center'
|
|
26
|
+
| 'left'
|
|
27
|
+
| 'right'
|
|
28
|
+
| 'spaceAround'
|
|
29
|
+
| 'spaceBetween'
|
|
30
|
+
| 'spaceEvenly'
|
|
31
31
|
|
|
32
32
|
export type ConfigurationProps = Partial<{
|
|
33
33
|
size: ValueType
|
package/src/useContext.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useContext } from
|
|
2
|
-
import { get, pick } from
|
|
3
|
-
import { context } from
|
|
4
|
-
import { CONTEXT_KEYS } from
|
|
5
|
-
import type { Context, Obj, ValueType } from
|
|
1
|
+
import { useContext } from '@pyreon/core'
|
|
2
|
+
import { get, pick } from '@pyreon/ui-core'
|
|
3
|
+
import { context } from '@pyreon/unistyle'
|
|
4
|
+
import { CONTEXT_KEYS } from './constants'
|
|
5
|
+
import type { Context, Obj, ValueType } from './types'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Picks only the recognized grid configuration keys from a props object,
|
|
@@ -29,12 +29,12 @@ type GetGridContext = (
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export const getGridContext: GetGridContext = (props = {}, theme = {}) => ({
|
|
32
|
-
columns: (get(props,
|
|
33
|
-
get(theme,
|
|
34
|
-
get(theme,
|
|
35
|
-
containerWidth: (get(props,
|
|
36
|
-
get(theme,
|
|
37
|
-
get(theme,
|
|
32
|
+
columns: (get(props, 'columns') ||
|
|
33
|
+
get(theme, 'grid.columns') ||
|
|
34
|
+
get(theme, 'coolgrid.columns')) as ValueType,
|
|
35
|
+
containerWidth: (get(props, 'width') ||
|
|
36
|
+
get(theme, 'grid.container') ||
|
|
37
|
+
get(theme, 'coolgrid.container')) as Record<string, number>,
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -44,7 +44,8 @@ export const getGridContext: GetGridContext = (props = {}, theme = {}) => ({
|
|
|
44
44
|
*/
|
|
45
45
|
type UseGridContext = (props: Obj) => Context
|
|
46
46
|
const useGridContext: UseGridContext = (props) => {
|
|
47
|
-
const
|
|
47
|
+
const getCtx = useContext(context)
|
|
48
|
+
const { theme } = getCtx()
|
|
48
49
|
const ctxProps = pickThemeProps(props, CONTEXT_KEYS)
|
|
49
50
|
const gridContext = getGridContext(ctxProps, theme as Record<string, unknown>)
|
|
50
51
|
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { omit } from
|
|
2
|
-
import { CONTEXT_KEYS } from
|
|
1
|
+
import { omit } from '@pyreon/ui-core'
|
|
2
|
+
import { CONTEXT_KEYS } from './constants'
|
|
3
3
|
|
|
4
4
|
/** Checks whether a value is a finite number. */
|
|
5
5
|
export const isNumber = (value: unknown): value is number => Number.isFinite(value)
|