@sigx/lynx-zero 0.4.9 → 0.5.0
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/LICENSE +21 -21
- package/README.md +25 -25
- package/dist/styles/tokens.css +98 -98
- package/dist/theme/ThemeProvider.d.ts +25 -1
- package/dist/theme/ThemeProvider.d.ts.map +1 -1
- package/dist/theme/ThemeProvider.js +17 -0
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/package.json +13 -8
- package/src/components/SwiperIndicator.tsx +519 -519
- package/src/contract.ts +136 -136
- package/src/index.ts +101 -101
- package/src/layout/Center.tsx +41 -41
- package/src/layout/Col.tsx +53 -53
- package/src/layout/Row.tsx +53 -53
- package/src/layout/ScrollView.tsx +38 -38
- package/src/layout/Spacer.tsx +18 -18
- package/src/preset/index.ts +77 -77
- package/src/shared/press.ts +6 -6
- package/src/shared/styles.ts +82 -82
- package/src/shared/tabs-selection.ts +57 -57
- package/src/styles/tokens.css +98 -98
- package/src/theme/StatusBarSync.tsx +104 -104
- package/src/theme/ThemeProvider.tsx +532 -492
- package/src/theme/color-mix.ts +68 -68
- package/src/theme/registry.ts +290 -290
- package/src/theme/theme-state.ts +112 -112
- package/src/theme/use-screen-theme.ts +42 -42
- package/src/theme/use-theme-colors.ts +99 -99
package/src/layout/Col.tsx
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { component, type Define } from '@sigx/lynx';
|
|
2
|
-
import type { BackgroundValue } from '../contract.js';
|
|
3
|
-
import { type SpacingValue, resolveBoxStyle } from '../shared/styles.js';
|
|
4
|
-
|
|
5
|
-
export type ColProps =
|
|
6
|
-
& Define.Prop<'gap', number, false>
|
|
7
|
-
& Define.Prop<'align', 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline', false>
|
|
8
|
-
& Define.Prop<'justify', 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly', false>
|
|
9
|
-
& Define.Prop<'wrap', boolean, false>
|
|
10
|
-
& Define.Prop<'padding', SpacingValue, false>
|
|
11
|
-
& Define.Prop<'margin', SpacingValue, false>
|
|
12
|
-
& Define.Prop<'width', number | string, false>
|
|
13
|
-
& Define.Prop<'height', number | string, false>
|
|
14
|
-
& Define.Prop<'flex', number, false>
|
|
15
|
-
& Define.Prop<'background', BackgroundValue, false>
|
|
16
|
-
& Define.Prop<'borderRadius', number, false>
|
|
17
|
-
& Define.Prop<'class', string, false>
|
|
18
|
-
& Define.Slot<'default'>;
|
|
19
|
-
|
|
20
|
-
export const Col = component<ColProps>(({ props, slots }) => {
|
|
21
|
-
const getStyle = (): Record<string, string | number> => {
|
|
22
|
-
const style: Record<string, string | number> = {
|
|
23
|
-
display: 'flex',
|
|
24
|
-
flexDirection: 'column',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
if (props.gap !== undefined) style.gap = props.gap;
|
|
28
|
-
if (props.align) style.alignItems = props.align;
|
|
29
|
-
if (props.justify) style.justifyContent = props.justify;
|
|
30
|
-
if (props.wrap) style.flexWrap = 'wrap';
|
|
31
|
-
|
|
32
|
-
const box = resolveBoxStyle({
|
|
33
|
-
width: props.width,
|
|
34
|
-
height: props.height,
|
|
35
|
-
flex: props.flex,
|
|
36
|
-
background: props.background,
|
|
37
|
-
borderRadius: props.borderRadius,
|
|
38
|
-
padding: props.padding,
|
|
39
|
-
margin: props.margin,
|
|
40
|
-
});
|
|
41
|
-
for (const key in box) {
|
|
42
|
-
style[key] = box[key] as string | number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return style;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return () => (
|
|
49
|
-
<view class={props.class} style={getStyle()}>
|
|
50
|
-
{slots.default?.()}
|
|
51
|
-
</view>
|
|
52
|
-
);
|
|
53
|
-
});
|
|
1
|
+
import { component, type Define } from '@sigx/lynx';
|
|
2
|
+
import type { BackgroundValue } from '../contract.js';
|
|
3
|
+
import { type SpacingValue, resolveBoxStyle } from '../shared/styles.js';
|
|
4
|
+
|
|
5
|
+
export type ColProps =
|
|
6
|
+
& Define.Prop<'gap', number, false>
|
|
7
|
+
& Define.Prop<'align', 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline', false>
|
|
8
|
+
& Define.Prop<'justify', 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly', false>
|
|
9
|
+
& Define.Prop<'wrap', boolean, false>
|
|
10
|
+
& Define.Prop<'padding', SpacingValue, false>
|
|
11
|
+
& Define.Prop<'margin', SpacingValue, false>
|
|
12
|
+
& Define.Prop<'width', number | string, false>
|
|
13
|
+
& Define.Prop<'height', number | string, false>
|
|
14
|
+
& Define.Prop<'flex', number, false>
|
|
15
|
+
& Define.Prop<'background', BackgroundValue, false>
|
|
16
|
+
& Define.Prop<'borderRadius', number, false>
|
|
17
|
+
& Define.Prop<'class', string, false>
|
|
18
|
+
& Define.Slot<'default'>;
|
|
19
|
+
|
|
20
|
+
export const Col = component<ColProps>(({ props, slots }) => {
|
|
21
|
+
const getStyle = (): Record<string, string | number> => {
|
|
22
|
+
const style: Record<string, string | number> = {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
flexDirection: 'column',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (props.gap !== undefined) style.gap = props.gap;
|
|
28
|
+
if (props.align) style.alignItems = props.align;
|
|
29
|
+
if (props.justify) style.justifyContent = props.justify;
|
|
30
|
+
if (props.wrap) style.flexWrap = 'wrap';
|
|
31
|
+
|
|
32
|
+
const box = resolveBoxStyle({
|
|
33
|
+
width: props.width,
|
|
34
|
+
height: props.height,
|
|
35
|
+
flex: props.flex,
|
|
36
|
+
background: props.background,
|
|
37
|
+
borderRadius: props.borderRadius,
|
|
38
|
+
padding: props.padding,
|
|
39
|
+
margin: props.margin,
|
|
40
|
+
});
|
|
41
|
+
for (const key in box) {
|
|
42
|
+
style[key] = box[key] as string | number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return style;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return () => (
|
|
49
|
+
<view class={props.class} style={getStyle()}>
|
|
50
|
+
{slots.default?.()}
|
|
51
|
+
</view>
|
|
52
|
+
);
|
|
53
|
+
});
|
package/src/layout/Row.tsx
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { component, type Define } from '@sigx/lynx';
|
|
2
|
-
import type { BackgroundValue } from '../contract.js';
|
|
3
|
-
import { type SpacingValue, resolveBoxStyle } from '../shared/styles.js';
|
|
4
|
-
|
|
5
|
-
export type RowProps =
|
|
6
|
-
& Define.Prop<'gap', number, false>
|
|
7
|
-
& Define.Prop<'align', 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline', false>
|
|
8
|
-
& Define.Prop<'justify', 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly', false>
|
|
9
|
-
& Define.Prop<'wrap', boolean, false>
|
|
10
|
-
& Define.Prop<'padding', SpacingValue, false>
|
|
11
|
-
& Define.Prop<'margin', SpacingValue, false>
|
|
12
|
-
& Define.Prop<'width', number | string, false>
|
|
13
|
-
& Define.Prop<'height', number | string, false>
|
|
14
|
-
& Define.Prop<'flex', number, false>
|
|
15
|
-
& Define.Prop<'background', BackgroundValue, false>
|
|
16
|
-
& Define.Prop<'borderRadius', number, false>
|
|
17
|
-
& Define.Prop<'class', string, false>
|
|
18
|
-
& Define.Slot<'default'>;
|
|
19
|
-
|
|
20
|
-
export const Row = component<RowProps>(({ props, slots }) => {
|
|
21
|
-
const getStyle = (): Record<string, string | number> => {
|
|
22
|
-
const style: Record<string, string | number> = {
|
|
23
|
-
display: 'flex',
|
|
24
|
-
flexDirection: 'row',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
if (props.gap !== undefined) style.gap = props.gap;
|
|
28
|
-
if (props.align) style.alignItems = props.align;
|
|
29
|
-
if (props.justify) style.justifyContent = props.justify;
|
|
30
|
-
if (props.wrap) style.flexWrap = 'wrap';
|
|
31
|
-
|
|
32
|
-
const box = resolveBoxStyle({
|
|
33
|
-
width: props.width,
|
|
34
|
-
height: props.height,
|
|
35
|
-
flex: props.flex,
|
|
36
|
-
background: props.background,
|
|
37
|
-
borderRadius: props.borderRadius,
|
|
38
|
-
padding: props.padding,
|
|
39
|
-
margin: props.margin,
|
|
40
|
-
});
|
|
41
|
-
for (const key in box) {
|
|
42
|
-
style[key] = box[key] as string | number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return style;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return () => (
|
|
49
|
-
<view class={props.class} style={getStyle()}>
|
|
50
|
-
{slots.default?.()}
|
|
51
|
-
</view>
|
|
52
|
-
);
|
|
53
|
-
});
|
|
1
|
+
import { component, type Define } from '@sigx/lynx';
|
|
2
|
+
import type { BackgroundValue } from '../contract.js';
|
|
3
|
+
import { type SpacingValue, resolveBoxStyle } from '../shared/styles.js';
|
|
4
|
+
|
|
5
|
+
export type RowProps =
|
|
6
|
+
& Define.Prop<'gap', number, false>
|
|
7
|
+
& Define.Prop<'align', 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline', false>
|
|
8
|
+
& Define.Prop<'justify', 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly', false>
|
|
9
|
+
& Define.Prop<'wrap', boolean, false>
|
|
10
|
+
& Define.Prop<'padding', SpacingValue, false>
|
|
11
|
+
& Define.Prop<'margin', SpacingValue, false>
|
|
12
|
+
& Define.Prop<'width', number | string, false>
|
|
13
|
+
& Define.Prop<'height', number | string, false>
|
|
14
|
+
& Define.Prop<'flex', number, false>
|
|
15
|
+
& Define.Prop<'background', BackgroundValue, false>
|
|
16
|
+
& Define.Prop<'borderRadius', number, false>
|
|
17
|
+
& Define.Prop<'class', string, false>
|
|
18
|
+
& Define.Slot<'default'>;
|
|
19
|
+
|
|
20
|
+
export const Row = component<RowProps>(({ props, slots }) => {
|
|
21
|
+
const getStyle = (): Record<string, string | number> => {
|
|
22
|
+
const style: Record<string, string | number> = {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
flexDirection: 'row',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (props.gap !== undefined) style.gap = props.gap;
|
|
28
|
+
if (props.align) style.alignItems = props.align;
|
|
29
|
+
if (props.justify) style.justifyContent = props.justify;
|
|
30
|
+
if (props.wrap) style.flexWrap = 'wrap';
|
|
31
|
+
|
|
32
|
+
const box = resolveBoxStyle({
|
|
33
|
+
width: props.width,
|
|
34
|
+
height: props.height,
|
|
35
|
+
flex: props.flex,
|
|
36
|
+
background: props.background,
|
|
37
|
+
borderRadius: props.borderRadius,
|
|
38
|
+
padding: props.padding,
|
|
39
|
+
margin: props.margin,
|
|
40
|
+
});
|
|
41
|
+
for (const key in box) {
|
|
42
|
+
style[key] = box[key] as string | number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return style;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return () => (
|
|
49
|
+
<view class={props.class} style={getStyle()}>
|
|
50
|
+
{slots.default?.()}
|
|
51
|
+
</view>
|
|
52
|
+
);
|
|
53
|
+
});
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { component, type Define } from '@sigx/lynx';
|
|
2
|
-
|
|
3
|
-
export type ScrollViewProps =
|
|
4
|
-
& Define.Prop<'direction', 'vertical' | 'horizontal', false>
|
|
5
|
-
& Define.Prop<'height', number | string, false>
|
|
6
|
-
& Define.Prop<'width', number | string, false>
|
|
7
|
-
& Define.Prop<'flex', number, false>
|
|
8
|
-
& Define.Prop<'showScrollbar', boolean, false>
|
|
9
|
-
& Define.Prop<'bounces', boolean, false>
|
|
10
|
-
& Define.Prop<'class', string, false>
|
|
11
|
-
& Define.Slot<'default'>;
|
|
12
|
-
|
|
13
|
-
export const ScrollView = component<ScrollViewProps>(({ props, slots }) => {
|
|
14
|
-
const getStyle = (): Record<string, string | number> => {
|
|
15
|
-
const style: Record<string, string | number> = {};
|
|
16
|
-
if (props.height !== undefined) style.height = props.height;
|
|
17
|
-
if (props.width !== undefined) style.width = props.width;
|
|
18
|
-
if (props.flex !== undefined) style.flex = props.flex;
|
|
19
|
-
return style;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
return () => {
|
|
23
|
-
const dir = props.direction ?? 'vertical';
|
|
24
|
-
return (
|
|
25
|
-
<scroll-view
|
|
26
|
-
class={props.class}
|
|
27
|
-
style={getStyle()}
|
|
28
|
-
scroll-orientation={dir}
|
|
29
|
-
scroll-y={dir === 'vertical' ? true : undefined}
|
|
30
|
-
scroll-x={dir === 'horizontal' ? true : undefined}
|
|
31
|
-
show-scrollbar={props.showScrollbar}
|
|
32
|
-
bounces={props.bounces}
|
|
33
|
-
>
|
|
34
|
-
{slots.default?.()}
|
|
35
|
-
</scroll-view>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
});
|
|
1
|
+
import { component, type Define } from '@sigx/lynx';
|
|
2
|
+
|
|
3
|
+
export type ScrollViewProps =
|
|
4
|
+
& Define.Prop<'direction', 'vertical' | 'horizontal', false>
|
|
5
|
+
& Define.Prop<'height', number | string, false>
|
|
6
|
+
& Define.Prop<'width', number | string, false>
|
|
7
|
+
& Define.Prop<'flex', number, false>
|
|
8
|
+
& Define.Prop<'showScrollbar', boolean, false>
|
|
9
|
+
& Define.Prop<'bounces', boolean, false>
|
|
10
|
+
& Define.Prop<'class', string, false>
|
|
11
|
+
& Define.Slot<'default'>;
|
|
12
|
+
|
|
13
|
+
export const ScrollView = component<ScrollViewProps>(({ props, slots }) => {
|
|
14
|
+
const getStyle = (): Record<string, string | number> => {
|
|
15
|
+
const style: Record<string, string | number> = {};
|
|
16
|
+
if (props.height !== undefined) style.height = props.height;
|
|
17
|
+
if (props.width !== undefined) style.width = props.width;
|
|
18
|
+
if (props.flex !== undefined) style.flex = props.flex;
|
|
19
|
+
return style;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return () => {
|
|
23
|
+
const dir = props.direction ?? 'vertical';
|
|
24
|
+
return (
|
|
25
|
+
<scroll-view
|
|
26
|
+
class={props.class}
|
|
27
|
+
style={getStyle()}
|
|
28
|
+
scroll-orientation={dir}
|
|
29
|
+
scroll-y={dir === 'vertical' ? true : undefined}
|
|
30
|
+
scroll-x={dir === 'horizontal' ? true : undefined}
|
|
31
|
+
show-scrollbar={props.showScrollbar}
|
|
32
|
+
bounces={props.bounces}
|
|
33
|
+
>
|
|
34
|
+
{slots.default?.()}
|
|
35
|
+
</scroll-view>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
});
|
package/src/layout/Spacer.tsx
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { component, type Define } from '@sigx/lynx';
|
|
2
|
-
|
|
3
|
-
export type SpacerProps =
|
|
4
|
-
& Define.Prop<'size', number, false>
|
|
5
|
-
& Define.Prop<'class', string, false>;
|
|
6
|
-
|
|
7
|
-
export const Spacer = component<SpacerProps>(({ props }) => {
|
|
8
|
-
const getStyle = (): Record<string, string | number> => {
|
|
9
|
-
if (props.size !== undefined) {
|
|
10
|
-
return { width: props.size, height: props.size };
|
|
11
|
-
}
|
|
12
|
-
return { flex: 1 };
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return () => (
|
|
16
|
-
<view class={props.class} style={getStyle()} />
|
|
17
|
-
);
|
|
18
|
-
});
|
|
1
|
+
import { component, type Define } from '@sigx/lynx';
|
|
2
|
+
|
|
3
|
+
export type SpacerProps =
|
|
4
|
+
& Define.Prop<'size', number, false>
|
|
5
|
+
& Define.Prop<'class', string, false>;
|
|
6
|
+
|
|
7
|
+
export const Spacer = component<SpacerProps>(({ props }) => {
|
|
8
|
+
const getStyle = (): Record<string, string | number> => {
|
|
9
|
+
if (props.size !== undefined) {
|
|
10
|
+
return { width: props.size, height: props.size };
|
|
11
|
+
}
|
|
12
|
+
return { flex: 1 };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return () => (
|
|
16
|
+
<view class={props.class} style={getStyle()} />
|
|
17
|
+
);
|
|
18
|
+
});
|
package/src/preset/index.ts
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import type { Config } from 'tailwindcss';
|
|
2
|
-
import plugin from 'tailwindcss/plugin';
|
|
3
|
-
import { COLOR_VARIANT_LIST } from '../contract.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The design-system-neutral Tailwind preset pieces — the parts of a DS preset
|
|
7
|
-
* that are really the *contract*, not the design system:
|
|
8
|
-
*
|
|
9
|
-
* • `contractColors`: every semantic color token (incl. the `*-soft`
|
|
10
|
-
* tints) → `var(--color-*)`, so utilities like `bg-primary` and
|
|
11
|
-
* `text-base-content` resolve against the active theme of whichever
|
|
12
|
-
* design system is mounted.
|
|
13
|
-
* • `contractFontSizes`: re-points Tailwind's `text-xs`…`text-3xl`
|
|
14
|
-
* font-size utilities at the shared `--text-*` ramp (defaults in
|
|
15
|
-
* `styles/tokens.css`, multiplied app-wide by the theme controller's
|
|
16
|
-
* `fontScale`). Merged via `theme.extend.fontSize`, so larger Tailwind
|
|
17
|
-
* keys (`text-4xl`+) keep their rem defaults.
|
|
18
|
-
* • `lynxLayoutPlugin`: ships `flex-fill` — the Lynx-correct "fill
|
|
19
|
-
* remaining space" utility. In Lynx (like React Native) the `flex: 1`
|
|
20
|
-
* shorthand expands to `flex: 1 1 auto`, where `flexBasis: 'auto'` sizes
|
|
21
|
-
* the box to its content first, collapsing the layout chain; Tailwind's
|
|
22
|
-
* own `flex-1` expands to the same broken shorthand. `flex-fill` writes
|
|
23
|
-
* the long-form properties so the result actually fills.
|
|
24
|
-
*
|
|
25
|
-
* Design-system presets compose these (`@sigx/lynx-daisyui/preset`,
|
|
26
|
-
* `@sigx/lynx-heroui/preset`) and layer any DS-specific extensions on top;
|
|
27
|
-
* apps normally consume the DS preset, not this one directly.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
export const contractColors: Record<string, string> = Object.fromEntries([
|
|
31
|
-
...COLOR_VARIANT_LIST.flatMap((v) => [
|
|
32
|
-
[v, `var(--color-${v})`],
|
|
33
|
-
[`${v}-content`, `var(--color-${v}-content)`],
|
|
34
|
-
[`${v}-soft`, `var(--color-${v}-soft)`],
|
|
35
|
-
]),
|
|
36
|
-
['base-100', 'var(--color-base-100)'],
|
|
37
|
-
['base-200', 'var(--color-base-200)'],
|
|
38
|
-
['base-300', 'var(--color-base-300)'],
|
|
39
|
-
['base-content', 'var(--color-base-content)'],
|
|
40
|
-
]);
|
|
41
|
-
|
|
42
|
-
export const contractFontSizes: Record<string, string> = {
|
|
43
|
-
'xs': 'var(--text-xs)',
|
|
44
|
-
'sm': 'var(--text-sm)',
|
|
45
|
-
'base': 'var(--text-base)',
|
|
46
|
-
'lg': 'var(--text-lg)',
|
|
47
|
-
'xl': 'var(--text-xl)',
|
|
48
|
-
'2xl': 'var(--text-2xl)',
|
|
49
|
-
'3xl': 'var(--text-3xl)',
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const lynxLayoutPlugin = plugin(({ addUtilities }) => {
|
|
53
|
-
addUtilities({
|
|
54
|
-
// Long-form flex-fill — the Lynx-correct "take remaining space along
|
|
55
|
-
// the main axis" utility. Default flex direction column; consumers
|
|
56
|
-
// who want a horizontal fill compose with `flex-row` on the parent.
|
|
57
|
-
'.flex-fill': {
|
|
58
|
-
flexGrow: '1',
|
|
59
|
-
flexShrink: '1',
|
|
60
|
-
flexBasis: '0',
|
|
61
|
-
minHeight: '0',
|
|
62
|
-
display: 'flex',
|
|
63
|
-
flexDirection: 'column',
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
/** The composed neutral preset — what DS presets spread. */
|
|
69
|
-
export const zeroPreset: Partial<Config> = {
|
|
70
|
-
theme: {
|
|
71
|
-
extend: {
|
|
72
|
-
colors: contractColors,
|
|
73
|
-
fontSize: contractFontSizes,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
plugins: [lynxLayoutPlugin],
|
|
77
|
-
};
|
|
1
|
+
import type { Config } from 'tailwindcss';
|
|
2
|
+
import plugin from 'tailwindcss/plugin';
|
|
3
|
+
import { COLOR_VARIANT_LIST } from '../contract.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The design-system-neutral Tailwind preset pieces — the parts of a DS preset
|
|
7
|
+
* that are really the *contract*, not the design system:
|
|
8
|
+
*
|
|
9
|
+
* • `contractColors`: every semantic color token (incl. the `*-soft`
|
|
10
|
+
* tints) → `var(--color-*)`, so utilities like `bg-primary` and
|
|
11
|
+
* `text-base-content` resolve against the active theme of whichever
|
|
12
|
+
* design system is mounted.
|
|
13
|
+
* • `contractFontSizes`: re-points Tailwind's `text-xs`…`text-3xl`
|
|
14
|
+
* font-size utilities at the shared `--text-*` ramp (defaults in
|
|
15
|
+
* `styles/tokens.css`, multiplied app-wide by the theme controller's
|
|
16
|
+
* `fontScale`). Merged via `theme.extend.fontSize`, so larger Tailwind
|
|
17
|
+
* keys (`text-4xl`+) keep their rem defaults.
|
|
18
|
+
* • `lynxLayoutPlugin`: ships `flex-fill` — the Lynx-correct "fill
|
|
19
|
+
* remaining space" utility. In Lynx (like React Native) the `flex: 1`
|
|
20
|
+
* shorthand expands to `flex: 1 1 auto`, where `flexBasis: 'auto'` sizes
|
|
21
|
+
* the box to its content first, collapsing the layout chain; Tailwind's
|
|
22
|
+
* own `flex-1` expands to the same broken shorthand. `flex-fill` writes
|
|
23
|
+
* the long-form properties so the result actually fills.
|
|
24
|
+
*
|
|
25
|
+
* Design-system presets compose these (`@sigx/lynx-daisyui/preset`,
|
|
26
|
+
* `@sigx/lynx-heroui/preset`) and layer any DS-specific extensions on top;
|
|
27
|
+
* apps normally consume the DS preset, not this one directly.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export const contractColors: Record<string, string> = Object.fromEntries([
|
|
31
|
+
...COLOR_VARIANT_LIST.flatMap((v) => [
|
|
32
|
+
[v, `var(--color-${v})`],
|
|
33
|
+
[`${v}-content`, `var(--color-${v}-content)`],
|
|
34
|
+
[`${v}-soft`, `var(--color-${v}-soft)`],
|
|
35
|
+
]),
|
|
36
|
+
['base-100', 'var(--color-base-100)'],
|
|
37
|
+
['base-200', 'var(--color-base-200)'],
|
|
38
|
+
['base-300', 'var(--color-base-300)'],
|
|
39
|
+
['base-content', 'var(--color-base-content)'],
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export const contractFontSizes: Record<string, string> = {
|
|
43
|
+
'xs': 'var(--text-xs)',
|
|
44
|
+
'sm': 'var(--text-sm)',
|
|
45
|
+
'base': 'var(--text-base)',
|
|
46
|
+
'lg': 'var(--text-lg)',
|
|
47
|
+
'xl': 'var(--text-xl)',
|
|
48
|
+
'2xl': 'var(--text-2xl)',
|
|
49
|
+
'3xl': 'var(--text-3xl)',
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const lynxLayoutPlugin = plugin(({ addUtilities }) => {
|
|
53
|
+
addUtilities({
|
|
54
|
+
// Long-form flex-fill — the Lynx-correct "take remaining space along
|
|
55
|
+
// the main axis" utility. Default flex direction column; consumers
|
|
56
|
+
// who want a horizontal fill compose with `flex-row` on the parent.
|
|
57
|
+
'.flex-fill': {
|
|
58
|
+
flexGrow: '1',
|
|
59
|
+
flexShrink: '1',
|
|
60
|
+
flexBasis: '0',
|
|
61
|
+
minHeight: '0',
|
|
62
|
+
display: 'flex',
|
|
63
|
+
flexDirection: 'column',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/** The composed neutral preset — what DS presets spread. */
|
|
69
|
+
export const zeroPreset: Partial<Config> = {
|
|
70
|
+
theme: {
|
|
71
|
+
extend: {
|
|
72
|
+
colors: contractColors,
|
|
73
|
+
fontSize: contractFontSizes,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
plugins: [lynxLayoutPlugin],
|
|
77
|
+
};
|
package/src/shared/press.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Shared press-feedback defaults applied across interactive components in
|
|
2
|
-
// every design system. Lynx has no CSS `:active` support, so press feedback
|
|
3
|
-
// comes from `<Pressable>` (in `@sigx/lynx-gestures`) flipping inline
|
|
4
|
-
// opacity/transform on the main thread.
|
|
5
|
-
export const PRESSED_SCALE = 0.97;
|
|
6
|
-
export const PRESSED_OPACITY = 0.85;
|
|
1
|
+
// Shared press-feedback defaults applied across interactive components in
|
|
2
|
+
// every design system. Lynx has no CSS `:active` support, so press feedback
|
|
3
|
+
// comes from `<Pressable>` (in `@sigx/lynx-gestures`) flipping inline
|
|
4
|
+
// opacity/transform on the main thread.
|
|
5
|
+
export const PRESSED_SCALE = 0.97;
|
|
6
|
+
export const PRESSED_OPACITY = 0.85;
|