@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/src/constants.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const PKG_NAME = "@pyreon/coolgrid"
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
- "columns",
11
- "size",
12
- "gap",
13
- "padding",
14
- "gutter",
15
- "colCss",
16
- "colComponent",
17
- "rowCss",
18
- "rowComponent",
19
- "contentAlignX",
10
+ 'columns',
11
+ 'size',
12
+ 'gap',
13
+ 'padding',
14
+ 'gutter',
15
+ 'colCss',
16
+ 'colComponent',
17
+ 'rowCss',
18
+ 'rowComponent',
19
+ 'contentAlignX',
20
20
  ]
@@ -1,5 +1,5 @@
1
- import { createContext } from "@pyreon/core"
2
- import type { Context as ContextType } from "../types"
1
+ import { createContext } from '@pyreon/core'
2
+ import type { Context as ContextType } from '../types'
3
3
 
4
4
  /**
5
5
  * Context for container-level grid configuration.
@@ -1,5 +1,5 @@
1
- import { createContext } from "@pyreon/core"
2
- import type { Context as ContextType } from "../types"
1
+ import { createContext } from '@pyreon/core'
2
+ import type { Context as ContextType } from '../types'
3
3
 
4
4
  /**
5
5
  * Context for row-level grid configuration.
@@ -1,4 +1,4 @@
1
- import ContainerContext from "./ContainerContext"
2
- import RowContext from "./RowContext"
1
+ import ContainerContext from './ContainerContext'
2
+ import RowContext from './RowContext'
3
3
 
4
4
  export { ContainerContext, RowContext }
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
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"
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: "100%",
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: "100%",
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 "@pyreon/core"
9
- import type { BreakpointKeys, config } from "@pyreon/ui-core"
10
- import type { AlignContentAlignXKeys, extendCss } from "@pyreon/unistyle"
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
- | "center"
26
- | "left"
27
- | "right"
28
- | "spaceAround"
29
- | "spaceBetween"
30
- | "spaceEvenly"
25
+ | 'center'
26
+ | 'left'
27
+ | 'right'
28
+ | 'spaceAround'
29
+ | 'spaceBetween'
30
+ | 'spaceEvenly'
31
31
 
32
32
  export type ConfigurationProps = Partial<{
33
33
  size: ValueType
@@ -1,8 +1,8 @@
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"
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, "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>,
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 { theme } = useContext(context)
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 "@pyreon/ui-core"
2
- import { CONTEXT_KEYS } from "./constants"
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)