@lightspeed/crane-api 2.3.3-rc.0 → 2.3.3-rc.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.
- package/CHANGELOG.md +2 -2
- package/README.md +81 -5
- package/dist/index.d.mts +2230 -381
- package/dist/index.d.ts +2230 -381
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 2.3.3 - 2026-
|
|
3
|
+
## 2.3.3 - 2026-06-03
|
|
4
4
|
|
|
5
5
|
### Fixed
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Support nested DECK defaults in showcase configuration; validate nested deck card setting keys recursively.
|
|
8
8
|
|
|
9
9
|
## 2.3.2 - 2026-05-21
|
|
10
10
|
|
package/README.md
CHANGED
|
@@ -42,8 +42,59 @@ import type { ContentType, DesignType } from './type';
|
|
|
42
42
|
|
|
43
43
|
export default createVueClientApp<ContentType, DesignType>(Section);
|
|
44
44
|
```
|
|
45
|
+
## UI Helpers
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
Higher-level composables and utilities that reduce boilerplate in template development. Import from `@lightspeed/crane-api`:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import {
|
|
51
|
+
useCurrentLanguage,
|
|
52
|
+
useBackgroundStyle,
|
|
53
|
+
useButtonStyles,
|
|
54
|
+
createTextStyle,
|
|
55
|
+
getColorHex,
|
|
56
|
+
getBackgroundStyle,
|
|
57
|
+
getContrastTextColor,
|
|
58
|
+
isColorDark,
|
|
59
|
+
} from '@lightspeed/crane-api';
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Composables
|
|
63
|
+
|
|
64
|
+
#### `useCurrentLanguage()`
|
|
65
|
+
|
|
66
|
+
Returns the current language code from site context with fallback chain: selected → main → `'en'`.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const { currentLanguage } = useCurrentLanguage();
|
|
70
|
+
// currentLanguage.value === 'en' | 'nl' | 'fr' | ...
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### `useBackgroundStyle(backgroundDesign, options?)`
|
|
74
|
+
|
|
75
|
+
Creates reactive CSS background styles from `BackgroundDesignData`. Supports solid colors and gradients.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
const bg = useBackgroundElementDesign<DesignType>('section_bg');
|
|
79
|
+
const bgStyle = useBackgroundStyle(bg, { direction: 'to bottom' });
|
|
80
|
+
// <div :style="bgStyle">
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### `useButtonStyles(buttonDesign, options?)`
|
|
84
|
+
|
|
85
|
+
Generates button CSS styles from `ButtonDesignData`. Handles size, appearance, shape, and auto contrast text color for solid buttons.
|
|
86
|
+
|
|
87
|
+
> **Note:** `fontWeight` is always set to `'400'`. Unlike `createTextStyle`, button styles intentionally ignore any bold-related properties — weight is expected to be controlled by the component's own CSS.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const btn = useButtonElementDesign<DesignType>('cta_button');
|
|
91
|
+
const btnStyle = useButtonStyles(btn, {
|
|
92
|
+
sizes: { large: { fontSize: '20px', padding: '16px 32px' } },
|
|
93
|
+
});
|
|
94
|
+
// <button :style="btnStyle">
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Content Composables
|
|
47
98
|
|
|
48
99
|
Access content defined in `settings/content.ts`:
|
|
49
100
|
|
|
@@ -63,7 +114,7 @@ Access content defined in `settings/content.ts`:
|
|
|
63
114
|
| `useNavigationMenuElementContent` | NAVIGATION_MENU | `Reactive<MenuContent>` |
|
|
64
115
|
| `useTranslation` | — | Translation helper |
|
|
65
116
|
|
|
66
|
-
|
|
117
|
+
#### Example
|
|
67
118
|
|
|
68
119
|
```typescript
|
|
69
120
|
import { useInputboxElementContent, useImageElementContent } from '@lightspeed/crane-api';
|
|
@@ -74,7 +125,7 @@ const image = useImageElementContent<ContentType>('hero_image');
|
|
|
74
125
|
|
|
75
126
|
```
|
|
76
127
|
|
|
77
|
-
|
|
128
|
+
### Design Composables
|
|
78
129
|
|
|
79
130
|
Access design settings defined in `settings/design.ts`:
|
|
80
131
|
|
|
@@ -90,7 +141,7 @@ Access design settings defined in `settings/design.ts`:
|
|
|
90
141
|
| `useLayoutElementDesign` | — | `Reactive<LayoutDesignData>` |
|
|
91
142
|
| `useLogoElementDesign` | LOGO | `ComputedRef<LogoDesignData>` |
|
|
92
143
|
|
|
93
|
-
|
|
144
|
+
#### Example
|
|
94
145
|
|
|
95
146
|
```typescript
|
|
96
147
|
import { useTextElementDesign, useBackgroundElementDesign } from '@lightspeed/crane-api';
|
|
@@ -101,7 +152,7 @@ const background = useBackgroundElementDesign<DesignType>('section_background');
|
|
|
101
152
|
|
|
102
153
|
```
|
|
103
154
|
|
|
104
|
-
|
|
155
|
+
### Working with DECK
|
|
105
156
|
|
|
106
157
|
DECK allows collections of cards. Use `getReactiveRef` to access card fields:
|
|
107
158
|
|
|
@@ -118,6 +169,31 @@ slides.cards?.forEach(card => {
|
|
|
118
169
|
});
|
|
119
170
|
```
|
|
120
171
|
|
|
172
|
+
### Utility Functions
|
|
173
|
+
|
|
174
|
+
| Function | Arguments | Description |
|
|
175
|
+
|----------|-----------|--------------------------------------------------------------------------------------------|
|
|
176
|
+
| `createTextStyle(design, options?)` | `design`: TextDesignData; `options?`: style defaults/overrides | Creates CSS properties from `TextDesignData` (font, size, color, bold, italic, visibility) |
|
|
177
|
+
| `getColorHex(color, fallback?)` | `color`: color-like value; `fallback?`: hex fallback | Extracts hex string from a `Color` object, string, or undefined |
|
|
178
|
+
| `getBackgroundStyle(design, options?)` | `design`: BackgroundDesignData; `options?`: gradient direction/fallbacks | Returns CSS background style object |
|
|
179
|
+
| `isColorDark(color)` | `color`: color-like value | Returns `true` when the color is considered dark |
|
|
180
|
+
| `getContrastTextColor(backgroundColor, darkTextColor?, lightTextColor?)` | `backgroundColor`: required; `darkTextColor?`: text for light backgrounds; `lightTextColor?`: text for dark backgrounds | Returns a readable contrast text color for the given background |
|
|
181
|
+
| `getCurrentLanguageCode(languages)` | `languages`: `Language[] \| undefined` | Returns current language code from an array of site languages. Fallback chain: selected → main → `'en'` |
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// createTextStyle — use inside computed for reactivity
|
|
185
|
+
const titleDesign = useTextElementDesign<DesignType>('title');
|
|
186
|
+
const titleStyle = computed(() => createTextStyle(titleDesign, {
|
|
187
|
+
defaultFont: 'Inter',
|
|
188
|
+
defaultSize: 24,
|
|
189
|
+
}));
|
|
190
|
+
|
|
191
|
+
// contrast helpers
|
|
192
|
+
const dark = isColorDark('#1a1a2e'); // true
|
|
193
|
+
const textColor = getContrastTextColor('#1a2e1a'); // '#FFFFFF'
|
|
194
|
+
const textColorCustom = getContrastTextColor('#1a2e1a', '#111111', '#FAFAFA');
|
|
195
|
+
```
|
|
196
|
+
|
|
121
197
|
## Requirements
|
|
122
198
|
|
|
123
199
|
- Node.js >= 20
|