@flow-os/style 0.0.1-dev.1772055921 → 0.0.1-dev.1772056336

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.
@@ -1,18 +1,11 @@
1
1
  /* Base reset */
2
- html,
3
- body {
4
- margin: 0;
5
- padding: 0;
6
- min-height: 100vh;
7
- }
8
2
 
9
- #app {
10
- min-height: 100vh;
11
- box-sizing: border-box;
3
+ :root {
4
+ --background: rgb(18, 18, 18)
5
+
12
6
  }
13
7
 
14
- *,
15
- *::before,
16
- *::after {
17
- box-sizing: inherit;
8
+ body {
9
+ background: var(--background);
10
+ color: #fff;
18
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flow-os/style",
3
- "version": "0.0.1-dev.1772055921",
3
+ "version": "0.0.1-dev.1772056336",
4
4
  "license": "PolyForm-Shield-1.0.0",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -13,7 +13,23 @@
13
13
  "types": "./src/index.ts",
14
14
  "import": "./src/index.ts",
15
15
  "default": "./src/index.ts"
16
- }
16
+ },
17
+ "./features/s": {
18
+ "types": "./src/features/s/index.ts",
19
+ "import": "./src/features/s/index.ts",
20
+ "default": "./src/features/s/index.ts"
21
+ },
22
+ "./features/styleFlow": {
23
+ "types": "./src/features/styleFlow/index.ts",
24
+ "import": "./src/features/styleFlow/index.ts",
25
+ "default": "./src/features/styleFlow/index.ts"
26
+ },
27
+ "./features/elements": {
28
+ "types": "./src/features/elements/index.ts",
29
+ "import": "./src/features/elements/index.ts",
30
+ "default": "./src/features/elements/index.ts"
31
+ },
32
+ "./config/client/root.css": "./config/client/root.css"
17
33
  },
18
34
  "dependencies": {}
19
35
  }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Applies `s` and `styleFlow` props to an HTMLElement.
3
+ * Used by the JSX runtime to override/extend element styling.
4
+ */
5
+
6
+ import { resolveS } from '../s';
7
+ import type { SValue } from '../../types';
8
+ import type { StyleFlowTheme } from '../styleFlow';
9
+
10
+ export interface StyleProps {
11
+ s?: SValue;
12
+ styleFlow?: StyleFlowTheme | string;
13
+ }
14
+
15
+ export function applyStyleProps(el: HTMLElement, props: StyleProps): void {
16
+ const { s, styleFlow } = props;
17
+
18
+ if (s != null) {
19
+ const resolved = resolveS(s);
20
+ if (resolved.className) {
21
+ const existing = el.className ? `${el.className} ` : '';
22
+ el.className = `${existing}${resolved.className}`;
23
+ }
24
+ if (resolved.style) {
25
+ for (const [k, v] of Object.entries(resolved.style)) {
26
+ (el.style as unknown as Record<string, string>)[k] = v;
27
+ }
28
+ }
29
+ }
30
+
31
+ if (styleFlow != null) {
32
+ if (typeof styleFlow === 'string') {
33
+ el.setAttribute('data-style-flow', styleFlow);
34
+ } else if (typeof styleFlow === 'object') {
35
+ el.setAttribute('data-style-flow', JSON.stringify(styleFlow));
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Element overrides - applies s and styleFlow to HTML elements.
3
+ */
4
+
5
+ export { applyStyleProps } from './apply';
6
+ export type { StyleProps } from './apply';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * `s` - shorthand for applying styles to elements.
3
+ * Accepts: string (class names) or object (inline CSS).
4
+ */
5
+
6
+ import type { SResult } from './types';
7
+
8
+ export type { SResult, SValue } from './types';
9
+
10
+ function cssProp(js: string): string {
11
+ return js.replace(/([A-Z])/g, '-$1').toLowerCase();
12
+ }
13
+
14
+ export function resolveS(s: string | Record<string, string | number | undefined>): SResult {
15
+ if (typeof s === 'string') {
16
+ return { className: s.trim() || undefined };
17
+ }
18
+ if (s && typeof s === 'object') {
19
+ const style: Record<string, string> = {};
20
+ for (const [k, v] of Object.entries(s)) {
21
+ if (v != null && v !== '') style[cssProp(k)] = String(v);
22
+ }
23
+ return Object.keys(style).length ? { style } : {};
24
+ }
25
+ return {};
26
+ }
@@ -0,0 +1,10 @@
1
+ /** Types for the `s` shorthand prop */
2
+
3
+ import type { SValue } from '../../types';
4
+
5
+ export type { SValue };
6
+
7
+ export interface SResult {
8
+ className?: string;
9
+ style?: Record<string, string>;
10
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * styleFlow - design system and theme.
3
+ * Provides tokens and utilities for consistent styling.
4
+ */
5
+
6
+ export { tokens } from './tokens';
7
+ export type { StyleFlowTheme } from './types';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Design tokens - CSS variables and theme values.
3
+ * Extend or override as needed per project.
4
+ */
5
+
6
+ import type { StyleFlowTheme } from './types';
7
+
8
+ export const tokens: StyleFlowTheme = {
9
+ color: {
10
+ background: 'rgb(18, 18, 18)',
11
+ foreground: '#fff',
12
+ },
13
+ radius: {
14
+ sm: '4px',
15
+ md: '8px',
16
+ lg: '12px',
17
+ },
18
+ space: {
19
+ xs: '4px',
20
+ sm: '8px',
21
+ md: '16px',
22
+ lg: '24px',
23
+ },
24
+ };
@@ -0,0 +1,5 @@
1
+ /** Types for the styleFlow design system */
2
+
3
+ import type { StyleFlowTheme } from '../../types';
4
+
5
+ export type { StyleFlowTheme };
package/src/index.ts CHANGED
@@ -1,2 +1,16 @@
1
+ /**
2
+ * @flow-os/style
3
+ *
4
+ * Style system for Flow OS: s (shorthand) and styleFlow (design tokens).
5
+ * Override HTML elements by using s and styleFlow props in JSX.
6
+ */
1
7
 
2
- export {};
8
+ // Features
9
+ export { resolveS } from './features/s';
10
+ export type { SValue, SResult } from './features/s';
11
+
12
+ export { tokens } from './features/styleFlow';
13
+ export type { StyleFlowTheme } from './features/styleFlow';
14
+
15
+ export { applyStyleProps } from './features/elements';
16
+ export type { StyleProps } from './features/elements';
package/src/jsx.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ declare global {
2
+ namespace JSX {
3
+ interface IntrinsicAttributes {
4
+ /** Shorthand: class names (string) or inline styles (object) */
5
+ s?: string | Record<string, string | number | undefined>;
6
+ /** Design system / theme token reference */
7
+ styleFlow?: Record<string, unknown> | string;
8
+ }
9
+ }
10
+ }
11
+
12
+ export {};
@@ -0,0 +1,9 @@
1
+ /** Shared types for @flow-os/style */
2
+
3
+ export type SValue = string | Record<string, string | number | undefined>;
4
+
5
+ export type StyleFlowToken = string | number;
6
+
7
+ export interface StyleFlowTheme {
8
+ [key: string]: StyleFlowToken | StyleFlowTheme;
9
+ }