@fasteros/themes 1.0.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/README.md ADDED
@@ -0,0 +1,310 @@
1
+ # [FasterOS](https://fasteros.com/api)
2
+ [![price](https://img.shields.io/badge/price-COMMERCIAL-blue)](https://fasteros.com/license)
3
+
4
+ FasterOS is a set of tools to accelerate software development.
5
+
6
+ # [Faster Themes](https://fasteros.com/api)
7
+ [![Passing](https://img.shields.io/badge/Passing-Angular_19-green)](https://fasteros.com/license) [![Passing](https://img.shields.io/badge/Passing-Node_>=18.19.1-green)](https://fasteros.com/license)
8
+
9
+ A faster, better way to style code.
10
+
11
+ Faster Themes moves styling from static CSS into typed theme objects so it can be generated, swapped, and edited at runtime. No build step for restyles. No CSS hunt for a misbehaving class.
12
+
13
+ - **Free** — use any of the built-in generated themes, or generate your own at runtime from 13 palette presets × 5 style profiles × 5 purpose profiles.
14
+ - **Paid** — `$1/mo. per Theme Editor + $0.00003 per read/write` to author and host custom themes via [FasterOS](https://fasteros.com/api). A site with 100k monthly visits runs ~$4/mo. Hosting included.
15
+
16
+ ## [Demo Site](https://fasteros.com/api)
17
+
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm i @fasteros/themes @angular/animations
23
+ ```
24
+
25
+ Add `FasterThemesModule` to your `AppModule`:
26
+
27
+ ```ts
28
+ import { FasterThemesModule } from '@fasteros/themes';
29
+
30
+ @NgModule({
31
+ imports: [BrowserModule, FasterThemesModule],
32
+ declarations: [AppComponent],
33
+ bootstrap: [AppComponent],
34
+ })
35
+ export class AppModule {}
36
+ ```
37
+
38
+ That gives you the `n*` directives, the `<accordion>` component, the `<faster-theme-generator>` component, and the `FasterThemesService`.
39
+
40
+ ---
41
+
42
+ ## Two ways to get a theme
43
+
44
+ ### Option A — Generate one locally (free)
45
+
46
+ `<faster-theme-generator>` builds a full `FasterTheme` from four inputs and emits it via `(themeGenerated)`. No backend, no API key.
47
+
48
+ ```ts
49
+ import { Component } from '@angular/core';
50
+ import { FasterTheme } from '@fasteros/themes';
51
+
52
+ @Component({
53
+ selector: 'app-root',
54
+ template: `
55
+ <faster-theme-generator
56
+ themeStyle="modern"
57
+ purpose="dashboard"
58
+ palette="corporate"
59
+ layout="row wrap"
60
+ (themeGenerated)="theme = $event">
61
+ </faster-theme-generator>
62
+
63
+ <div nContainer="Wide" [theme]="theme">
64
+ <div nType="H1" [theme]="theme">Hello</div>
65
+ <div nButton="Default Style" [theme]="theme">Click me</div>
66
+ </div>
67
+ `,
68
+ })
69
+ export class AppComponent {
70
+ theme?: FasterTheme;
71
+ }
72
+ ```
73
+
74
+ You can also generate from TypeScript without putting the component in your template:
75
+
76
+ ```ts
77
+ import { ThemeGeneratorComponent } from '@fasteros/themes';
78
+
79
+ const gen = new ThemeGeneratorComponent();
80
+ gen.themeStyle = 'bold';
81
+ gen.purpose = 'form';
82
+ gen.palette = 'finance';
83
+ const theme = gen.generate();
84
+ ```
85
+
86
+ #### Generator inputs
87
+
88
+ | Input | Values | Effect |
89
+ |---|---|---|
90
+ | `themeStyle` | `modern`, `classic`, `minimal`, `bold`, `playful` | Font family, weights, border radius, shadows |
91
+ | `purpose` | `marketing`, `dashboard`, `documentation`, `form`, `gallery` | Padding density, button sizing, heading emphasis, accordion mode |
92
+ | `palette` | a preset name (see below) or a custom `Palette[]` | Color story (8 semantic roles) |
93
+ | `layout` | `row`, `row wrap` (default), `column`, etc. | Default `flex-flow` for containers and accordions |
94
+ | `elevation` | `none`, `small`, `medium` (default), `large` | Container/button box-shadow depth |
95
+ | `textShadow` | `none` (default), `small`, `medium`, `large` | Typography shadow depth |
96
+ | `name` | optional `string` | Override theme name (default: `"<Style> <Palette> <Purpose>"`) |
97
+ | `responsive*` | optional numbers | Override the seven responsive sizing knobs |
98
+
99
+ #### Palette presets
100
+
101
+ Each preset defines 8 semantic roles: `Primary`, `Secondary`, `Accent`, `Highlight`, `Surface`, `Muted`, `Subtle`, `Inverse`.
102
+
103
+ | Group | Presets |
104
+ |---|---|
105
+ | Aesthetic | `ocean`, `forest`, `sunset`, `monochrome`, `pastel` |
106
+ | Business | `corporate`, `healthcare`, `finance`, `tech`, `legal`, `hospitality`, `retail`, `education` |
107
+
108
+ ---
109
+
110
+ ### Option B — Load themes from FasterOS
111
+
112
+ Once you have:
113
+
114
+ - ✅ Created a Team on [FasterOS](https://fasteros.com/api)
115
+ - ✅ Generated an API key
116
+ - ✅ Created or selected a Theme
117
+
118
+ call `initThemes()` at startup:
119
+
120
+ ```ts
121
+ import { Component } from '@angular/core';
122
+ import { FasterThemesService } from '@fasteros/themes';
123
+
124
+ @Component({
125
+ selector: 'app-root',
126
+ templateUrl: './app.component.html',
127
+ })
128
+ export class AppComponent {
129
+ constructor(public fasterThemes: FasterThemesService) {
130
+ this.fasterThemes.initThemes('YOUR_API_KEY');
131
+ }
132
+ }
133
+ ```
134
+
135
+ The service fetches `{ companyId, themes: FasterTheme[] }` once at init and populates `fasterThemes.allThemes`. Pass an optional `themeId` as the second argument to load a single theme. On failure (missing key, network error, non-2xx) the call logs and returns silently — `getTheme()` falls back to the built-in `defaultStyle`.
136
+
137
+ Then refer to themes by name in your template:
138
+
139
+ ```html
140
+ <div *ngIf="fasterThemes.allThemes?.length">
141
+ <div nContainer="Full Width" theme="base">
142
+ <div nType="H1" theme="base">Headline</div>
143
+ <div nButton="Create" theme="base">Add</div>
144
+ </div>
145
+ </div>
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Using a theme
151
+
152
+ ### `n*` directives
153
+
154
+ Apply theme-driven styles to any element. They re-apply automatically when the bound theme reference changes.
155
+
156
+ ```html
157
+ <div nContainer="Wide" [theme]="theme">
158
+ <div nType="H1" [theme]="theme">Hello</div>
159
+ <div nButton="Default Style" [theme]="theme">Click me</div>
160
+ <div nColor="Primary" [theme]="theme">Tinted block</div>
161
+ <div nClass="justifyRight" [theme]="theme">Text on right</div>
162
+ </div>
163
+ ```
164
+
165
+ Each directive supports two equivalent forms — pick whichever reads best:
166
+
167
+ ```html
168
+ <div nContainer="Wide" [theme]="t">…</div> <!-- aliased value -->
169
+ <div nContainer container="Wide" [theme]="t">…</div> <!-- selector + named input -->
170
+ ```
171
+
172
+ `[theme]` accepts a `FasterTheme` object **or** a theme name string. Use `<div nButton>`, not `<button nButton>`.
173
+
174
+ ### Service methods (alternative to directives)
175
+
176
+ `FasterThemesService` exposes helpers that return CSS strings for direct `[style]` bindings — useful when you want to compose styles imperatively:
177
+
178
+ ```html
179
+ <div [style]="fasterThemes.container(theme, 'Wide')">
180
+ <div [style]="fasterThemes.type(theme, 'H1')">Hello</div>
181
+ <div [style]="fasterThemes.button(theme, 'Default Style')">Click me</div>
182
+ </div>
183
+ ```
184
+
185
+ | Method | Returns |
186
+ |---|---|
187
+ | `container(theme, name)` | CSS for the named container style |
188
+ | `type(theme, name)` | CSS for the named typography style |
189
+ | `button(theme, name)` | CSS for the named button style |
190
+ | `accordion(theme, name)` | CSS for the named accordion style |
191
+ | `header(theme, name, expanded, index)` | CSS for an accordion header in its current state |
192
+ | `class(theme, name)` | CSS for a named utility class |
193
+ | `getTheme(nameOrObject)` | Resolves a name or id to its `FasterTheme` (falls back to `defaultStyle`) |
194
+ | `getPalette(theme, paletteName)` | Looks up a palette entry by role name |
195
+
196
+ All accept either a `FasterTheme` object or a theme name string.
197
+
198
+ ### Accordion
199
+
200
+ ```html
201
+ <accordion accordionName="base" [themeName]="theme" [collapsing]="true">
202
+ <accordion-item *ngFor="let s of sections" [title]="s.title">
203
+ <ng-template accordionTitle>
204
+ <div nType="H4" [theme]="theme">{{ s.title }}</div>
205
+ </ng-template>
206
+ <ng-template accordionContent>
207
+ <div nType="body" [theme]="theme">{{ s.body }}</div>
208
+ </ng-template>
209
+ </accordion-item>
210
+ </accordion>
211
+ ```
212
+
213
+ #### `<accordion>` inputs
214
+
215
+ | Input | Type | Notes |
216
+ |---|---|---|
217
+ | `accordionName` | `string` | Which accordion style from the theme (e.g. `base`, `Docs`) |
218
+ | `themeName` | `FasterTheme \| string` | Theme object or theme name |
219
+ | `collapsing` | `boolean` | Only one item open at a time |
220
+ | `focus` | `boolean` | Other items hide while one is expanded (modal-like) |
221
+ | `(headerClicked)` | `{ index, open }` | Emits on every toggle |
222
+
223
+ `collapseAll()` is the public method to close everything.
224
+
225
+ #### `<accordion-item>` inputs
226
+
227
+ | Input | Notes |
228
+ |---|---|
229
+ | `title` | Item label, used by the default header template |
230
+ | `disabled` | Disables expand/collapse |
231
+ | `expanded` | Initial state |
232
+ | `closeOther` | Title of another item to close when this one opens |
233
+ | `loaded` | If `false`, content is lazy-loaded on first expand |
234
+
235
+ ### Ripple directive
236
+
237
+ ```html
238
+ <div ripple style="padding: 12px;">Click anywhere</div>
239
+ ```
240
+
241
+ `RippleDirective` is standalone and is auto-imported with `FasterThemesModule`. You can also import it directly into a standalone component.
242
+
243
+ ---
244
+
245
+ ## Responsive styling
246
+
247
+ A major benefit of code-driven styling is that responsiveness can be expressed mathematically rather than via media-query stair-steps.
248
+
249
+ Faster Themes provides seven responsive knobs per theme — `responsiveStandardWidth`, `responsiveFontSize{Min,Max}`, `responsiveMargin{Min,Max}`, `responsivePadding{Min,Max}` — that linearly interpolate text and white-space as the viewport scales. Set them via the generator inputs, the API, or directly on a theme object. End users can also adjust them at runtime if you choose to expose the controls.
250
+
251
+ ---
252
+
253
+ ## License
254
+ Faster themes is a usage-based platform governed by a commercial license.
255
+
256
+ https://fasteros.com/license
257
+
258
+ ## Support
259
+
260
+ https://fasteros.com/support
261
+
262
+ ## FAQ
263
+
264
+ #### Can I still use CSS & inline styling?
265
+
266
+ Yes, Faster themes does not limit your use of CSS or inline styling.
267
+
268
+ #### Is every CSS capability supported?
269
+
270
+ Faster themes objects allow direct addition of CSS if needed so no functionality is lost.
271
+
272
+ #### How many apps can we use our themes with?
273
+
274
+ There is no limit.
275
+
276
+ #### What is the pricing model?
277
+ Using generated themes is free.
278
+
279
+ Creating and deploying custom themes is usage based. A small team with about 10,000 end-user sessions/mo would expect to pay about $2/mo.
280
+
281
+ #### What are the limits of the free version?
282
+
283
+ The free version includes unlimited use of generated themes.
284
+
285
+ #### Do we own a theme we develop?
286
+
287
+ Yes. You can use any generated themes as a starting point to create custom themes. Any themes in your team account are your sole property.
288
+
289
+ #### We reported a bug, when should we expect a fix?
290
+
291
+ Faster themes is commercial software backed by a team of senior software engineers that take quality and performance very seriously. All reports of bugs are considered top priority. We also welcome all suggested improvements.
292
+
293
+ #### How does this accelerate software development?
294
+
295
+ Faster themes allows code to be written much faster with more consistent interfaces simply by moving styling from a static text file to code. This approach allows developers to focus on functionality and designers to make real-time improvements to the interface without the need for linear development cycles.
296
+
297
+ #### Can we give our users the ability to choose or modify themes?
298
+
299
+ Yes! You can let your users choose from a set of themes you create, modify themes, and offer control of responsive settings so they can optimize text and white space size.
300
+
301
+ #### What about code readability?
302
+
303
+ Your HTML will be self documenting and without cryptic styling shorthand.
304
+
305
+ #### Is there more coming?
306
+
307
+ Yes. We'll be releasing a robust set of UI elements and smart objects based on our Organic Object Model.
308
+
309
+
310
+ <!-- [![Copyright](https://img.shields.io/badge/Copyright-©_2023--2025_Napkin_Apps_Corp._All_rights_reserved.-green)](https://fasteros.com/license) -->