@startupjs-ui/core 0.1.1 → 0.1.2

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.
@@ -0,0 +1,10 @@
1
+ {
2
+ "main": ["#f2f4f8", "#dde1e6", "#c1c7cd", "#a2a9b0", "#878d96", "#697077", "#4d5358", "#343a3f", "#21272a", "#121619" ],
3
+ "error": ["#fff1f1", "#ffd7d9", "#ffb3b8", "#ff8389", "#fa4d56", "#da1e28", "#a2191f", "#750e13", "#520408", "#2d0709"],
4
+ "primary": ["#edf5ff", "#d0e2ff", "#a6c8ff", "#78a9ff", "#4589ff", "#0f62fe", "#0043ce", "#002d9c", "#001d6c", "#001141"],
5
+ "info": ["#e5f6ff", "#bae6ff", "#82cfff", "#33b1ff", "#1192e8", "#0072c3", "#00539a", "#003a6d", "#012749", "#061727"],
6
+ "success": ["#defbe6", "#a7f0ba", "#6fdc8c", "#42be65", "#24a148", "#198038", "#0e6027", "#044317", "#022d0d", "#071908"],
7
+ "attention": ["#ffd4a0", "#ffa573", "#ff7832", "#ff5003", "#d74108", "#a53725", "#872a0f", "#6d120f", "#43100b", "#030100"],
8
+ "warning": ["#fde876", "#fdd600", "#efc100", "#be9b00", "#8c7300", "#735f00", "#574a00", "#3c3200", "#281e00", "#020100"],
9
+ "secondary": ["#f2f4f8", "#dde1e6", "#c1c7cd", "#a2a9b0", "#878d96", "#697077", "#4d5358", "#343a3f", "#21272a", "#121619" ]
10
+ }
@@ -0,0 +1,66 @@
1
+ import React, { useContext } from 'react'
2
+ import { matcher } from 'startupjs'
3
+ import memoize from 'lodash/memoize'
4
+ import ThemeContext from './ThemeContext'
5
+ import { useStyle } from './StyleContext'
6
+
7
+ const memoizedMatcher = memoize(matcher, name => name)
8
+
9
+ // TODO: Move themed inside react-sharedb's observer()
10
+ export default function themed (name, Component) {
11
+ if (typeof name !== 'string') {
12
+ Component = name
13
+ name = Component.displayName || Component.name
14
+ }
15
+
16
+ function ThemeWrapper (props, ref) {
17
+ // Setup global component style overrides
18
+ const uiStyle = useStyle()
19
+
20
+ if (uiStyle) {
21
+ const styleProps = memoizedMatcher(name, uiStyle, '', '', {}) || {}
22
+ const keysLength = Object.keys(styleProps).length
23
+ if (
24
+ keysLength > 0 &&
25
+ // Handle special case when we have an empty style array
26
+ // TODO: Fix returning an empty style array
27
+ !(keysLength === 1 && Array.isArray(styleProps.style) && styleProps.style.length === 0)
28
+ ) {
29
+ const newStyleProps = {}
30
+ for (const key in styleProps) {
31
+ if (props[key]) {
32
+ newStyleProps[key] = [styleProps[key], props[key]]
33
+ } else {
34
+ newStyleProps[key] = styleProps[key]
35
+ }
36
+ }
37
+ props = { ...props, ...newStyleProps }
38
+ }
39
+ }
40
+
41
+ // Setup theme context
42
+ const contextTheme = useContext(ThemeContext)
43
+ const theme = props.theme || contextTheme
44
+ let res
45
+ if (theme && !props.theme) {
46
+ res = Component({ theme, ...props }, ref)
47
+ } else {
48
+ res = Component(props, ref)
49
+ }
50
+ return (props.theme && (!contextTheme || contextTheme !== props.theme))
51
+ ? (
52
+ React.createElement(
53
+ ThemeContext.Provider,
54
+ { value: props.theme },
55
+ res
56
+ )
57
+ )
58
+ : res
59
+ }
60
+
61
+ ThemeWrapper.displayName = Component.displayName || Component.name
62
+ ThemeWrapper.propTypes = Component.propTypes
63
+ ThemeWrapper.defaultProps = Component.defaultProps
64
+
65
+ return ThemeWrapper
66
+ }
@@ -0,0 +1,15 @@
1
+ import merge from 'lodash/merge'
2
+
3
+ export default function transformColors ({ colors = {}, palette = {}, componentColors = {} }) {
4
+ const transformedColors = Object.keys(colors).reduce((vars, color) => {
5
+ const prefix = color.includes('--color') ? '' : '--color-'
6
+ vars[`${prefix}${color}`] = colors[color]
7
+ return vars
8
+ }, {})
9
+
10
+ return merge({}, componentColors, Object.keys(palette).reduce((vars, color) => {
11
+ const prefix = color.includes('--palette') ? '' : '--palette-'
12
+ vars[`${prefix}${color}`] = palette[color]
13
+ return vars
14
+ }, transformedColors))
15
+ }
@@ -0,0 +1,44 @@
1
+ import { useMemo } from 'react'
2
+ import { setDefaultVariables } from 'startupjs'
3
+ import defaultPalette from './defaultPalette'
4
+ import defaultVariables from './defaultUiVariables'
5
+ import { transformOverrides } from './helpers'
6
+
7
+ // set default css variables as early as possible
8
+ setDefaultVariables(defaultVariables)
9
+
10
+ export default function useCssVariablesMeta ({ staticOverrides, palette, colors, componentColors }) {
11
+ const cssVariablesMeta = useMemo(() => {
12
+ // dynamic overrides take priority over static
13
+ if (palette || colors || componentColors) return { palette, colors, componentColors }
14
+
15
+ if (!staticOverrides) return
16
+
17
+ const meta = { palette: {}, colors: {}, componentColors: {} }
18
+
19
+ const transformedOverrides = transformOverrides(staticOverrides, defaultPalette.colors, defaultPalette.Color)
20
+
21
+ for (const key in transformedOverrides) {
22
+ const isColor = key.includes('--color')
23
+ const isPaletteColor = key.includes('--palette')
24
+
25
+ const value = transformedOverrides[key]
26
+
27
+ const path = isPaletteColor
28
+ ? 'palette'
29
+ : isColor
30
+ ? 'colors'
31
+ : 'componentColors'
32
+
33
+ meta[path][key] = value
34
+ }
35
+
36
+ return meta
37
+ }, [ // eslint-disable-line react-hooks/exhaustive-deps
38
+ JSON.stringify(staticOverrides), // eslint-disable-line react-hooks/exhaustive-deps
39
+ JSON.stringify(palette), // eslint-disable-line react-hooks/exhaustive-deps
40
+ JSON.stringify(colors), // eslint-disable-line react-hooks/exhaustive-deps
41
+ JSON.stringify(componentColors) // eslint-disable-line react-hooks/exhaustive-deps
42
+ ])
43
+ return cssVariablesMeta
44
+ }
package/CHANGELOG.md DELETED
@@ -1,9 +0,0 @@
1
- # v0.1.1 (Sun Nov 16 2025)
2
-
3
- #### ⚠️ Pushed to `master`
4
-
5
- - initial ([@cray0000](https://github.com/cray0000))
6
-
7
- #### Authors: 1
8
-
9
- - Pavel Zhukov ([@cray0000](https://github.com/cray0000))