@octaviaflow/themes 1.0.1

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.
Files changed (46) hide show
  1. package/README.md +122 -0
  2. package/docs/sass.md +189 -0
  3. package/index.scss +11 -0
  4. package/lib/index.js +5634 -0
  5. package/package.json +49 -0
  6. package/scss/_component-tokens.scss +10 -0
  7. package/scss/_config.scss +11 -0
  8. package/scss/_theme.scss +120 -0
  9. package/scss/_themes.scss +8 -0
  10. package/scss/_tokens.scss +8 -0
  11. package/scss/_utilities.scss +18 -0
  12. package/scss/compat/_themes.scss +8 -0
  13. package/scss/compat/_tokens.scss +8 -0
  14. package/scss/compat/generated/_themes.scss +271 -0
  15. package/scss/compat/generated/_tokens.scss +206 -0
  16. package/src/component-tokens/button/index.js +10 -0
  17. package/src/component-tokens/button/tokens.js +132 -0
  18. package/src/component-tokens/notification/index.js +10 -0
  19. package/src/component-tokens/notification/tokens.js +107 -0
  20. package/src/component-tokens/tag/index.js +10 -0
  21. package/src/component-tokens/tag/tokens.js +362 -0
  22. package/src/g10.js +346 -0
  23. package/src/g100.js +349 -0
  24. package/src/g90.js +350 -0
  25. package/src/index.js +42 -0
  26. package/src/tokens/Token.js +37 -0
  27. package/src/tokens/TokenFormat.js +91 -0
  28. package/src/tokens/TokenGroup.js +164 -0
  29. package/src/tokens/TokenSet.js +80 -0
  30. package/src/tokens/components.js +97 -0
  31. package/src/tokens/index.js +71 -0
  32. package/src/tokens/layout.js +42 -0
  33. package/src/tokens/type.js +52 -0
  34. package/src/tokens/v10.js +191 -0
  35. package/src/tokens/v11TokenGroup.js +436 -0
  36. package/src/tokens/v11TokenSet.js +94 -0
  37. package/src/tools.js +80 -0
  38. package/src/v10/g10.js +352 -0
  39. package/src/v10/g100.js +351 -0
  40. package/src/v10/g90.js +353 -0
  41. package/src/v10/index.js +25 -0
  42. package/src/v10/metadata.yml +217 -0
  43. package/src/v10/tokens.js +400 -0
  44. package/src/v10/white.js +355 -0
  45. package/src/white.js +349 -0
  46. package/telemetry.yml +17 -0
package/src/index.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright OctaviaFlow
3
+ * Author: Vishal Kumar
4
+ * Created: 11/November/2025
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ import * as white from './white';
12
+ import * as g10 from './g10';
13
+ import * as g90 from './g90';
14
+ import * as g100 from './g100';
15
+ import * as v10 from './v10';
16
+ import * as buttonTokens from './component-tokens/button';
17
+ import * as tagTokens from './component-tokens/tag';
18
+ import * as notificationTokens from './component-tokens/notification';
19
+ import { formatTokenName } from './tools';
20
+ import { unstable_metadata } from './tokens';
21
+
22
+ const themes = {
23
+ white,
24
+ g10,
25
+ g90,
26
+ g100,
27
+ };
28
+
29
+ export * from './white';
30
+ export {
31
+ white,
32
+ g10,
33
+ g90,
34
+ g100,
35
+ themes,
36
+ v10,
37
+ buttonTokens,
38
+ tagTokens,
39
+ notificationTokens,
40
+ unstable_metadata,
41
+ formatTokenName,
42
+ };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright OctaviaFlow
3
+ * Author: Vishal Kumar
4
+ * Created: 11/November/2025
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ /**
12
+ * A Token is the simplest unit in our theme. It can have a name, properties
13
+ * that it applies to like border or background, along with a state if the
14
+ * token should only be used for specific states like hover or focus.
15
+ */
16
+ export class Token {
17
+ static create(token) {
18
+ if (typeof token === 'string') {
19
+ return new Token(token);
20
+ }
21
+
22
+ return new Token(token.name, token.properties, token.state);
23
+ }
24
+
25
+ constructor(name, properties, state) {
26
+ this.kind = 'Token';
27
+ this.name = name;
28
+
29
+ if (properties) {
30
+ this.properties = properties;
31
+ }
32
+
33
+ if (state) {
34
+ this.state = state;
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Copyright OctaviaFlow
3
+ * Author: Vishal Kumar
4
+ * Created: 11/November/2025
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ const formats = {
12
+ js: 'javascript',
13
+ scss: 'scss',
14
+ };
15
+
16
+ export const TokenFormat = {
17
+ formats,
18
+
19
+ convert({ name, format }) {
20
+ if (format === formats.js) {
21
+ const keywords = new Set(['ui']);
22
+
23
+ return name
24
+ .split('-')
25
+ .map((part, index) => {
26
+ if (index === 0) {
27
+ return part;
28
+ }
29
+
30
+ if (keywords.has(part)) {
31
+ return part.toUpperCase();
32
+ }
33
+
34
+ return part[0].toUpperCase() + part.slice(1);
35
+ })
36
+ .join('');
37
+ }
38
+
39
+ if (format === formats.scss) {
40
+ return formatNameToScss(name);
41
+ }
42
+
43
+ return name;
44
+ },
45
+ };
46
+
47
+ const numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
48
+
49
+ /**
50
+ * Format a given token into the format expected in CSS/SCSS-based projects.
51
+ * @param {string} token
52
+ * @returns {string}
53
+ */
54
+ function formatNameToScss(token) {
55
+ let string = '';
56
+
57
+ for (let i = 0; i < token.length; i++) {
58
+ if (token[i] === '-') {
59
+ continue;
60
+ }
61
+
62
+ // If we run into a number, we hit the scale step at the end of a token name
63
+ // and can safely truncate the rest of the token
64
+ if (numbers.indexOf(token[i]) !== -1) {
65
+ string += '-' + token.slice(i);
66
+ break;
67
+ }
68
+
69
+ // When encountering an uppercase name, we will want to start adding `-`
70
+ // between words
71
+ if (token[i] === token[i].toUpperCase()) {
72
+ // Check backwards to see if previous letter was also capitalized, if so
73
+ // we are in a special case like UI where each piece should be connected
74
+ if (token[i - 1] && token[i - 1] === token[i - 1].toUpperCase()) {
75
+ string += token[i].toLowerCase();
76
+ continue;
77
+ }
78
+
79
+ if (token[i - 1] !== '-') {
80
+ // Otherwise, just concatenate this new part on to the existing string
81
+ string += '-' + token[i].toLowerCase();
82
+ }
83
+ continue;
84
+ }
85
+
86
+ // By default, we add the current character to the output string
87
+ string += token[i];
88
+ }
89
+
90
+ return string;
91
+ }
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Copyright OctaviaFlow
3
+ * Author: Vishal Kumar
4
+ * Created: 11/November/2025
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ import { Token } from './Token';
12
+
13
+ /**
14
+ * A TokenGroup allows us to group up a collection of tokens and nested token
15
+ * groups. A group allows us to colocate related tokens and write information
16
+ * once that applies to the entire collection of tokens. For example, if all the
17
+ * tokens apply to the `border` color property then we can specify this property
18
+ * at the group level
19
+ *
20
+ * A TokenGroup allows us to colocate all this information while also providing
21
+ * ways to get information about the entire group, including properties and
22
+ * states
23
+ */
24
+ export class TokenGroup {
25
+ static create({ name, properties, tokens = [] }) {
26
+ return new TokenGroup(name, tokens, properties);
27
+ }
28
+
29
+ constructor(name, tokens, properties) {
30
+ this.kind = 'TokenGroup';
31
+ this.name = name;
32
+
33
+ if (properties) {
34
+ this.properties = properties;
35
+ }
36
+
37
+ this.children = tokens.map((child) => {
38
+ if (child.kind === 'TokenGroup') {
39
+ return child;
40
+ }
41
+
42
+ return Token.create(child);
43
+ });
44
+ }
45
+
46
+ *[Symbol.iterator]() {
47
+ yield this;
48
+
49
+ for (const child of this.children) {
50
+ yield child;
51
+
52
+ if (child.kind === 'TokenGroup') {
53
+ yield* child;
54
+ }
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Get all the tokens available in every Token Group in this TokenGroup,
60
+ * including itself.
61
+ * @returns {Array<Token>}
62
+ */
63
+ getTokens(parentContext = {}) {
64
+ const context = {
65
+ ...parentContext,
66
+ groups: parentContext.groups ? parentContext.groups.concat(this) : [this],
67
+ properties: this.properties || parentContext.properties,
68
+ };
69
+
70
+ return this.children.flatMap((child) => {
71
+ if (child.kind === 'TokenGroup') {
72
+ return child.getTokens(context);
73
+ }
74
+
75
+ const token = {
76
+ ...context,
77
+ name: child.name,
78
+ properties: child.properties || context.properties,
79
+ };
80
+
81
+ if (child.state) {
82
+ token.state = child.state;
83
+ }
84
+
85
+ return token;
86
+ });
87
+ }
88
+
89
+ /**
90
+ * Get a specific token from the TokenGroup, or form one of its nested
91
+ * TokenGroups
92
+ * @returns {Token}
93
+ */
94
+ getToken(tokenOrName) {
95
+ const name =
96
+ typeof tokenOrName === 'string' ? tokenOrName : tokenOrName.name;
97
+ for (const child of this) {
98
+ if (child.kind === 'TokenGroup') {
99
+ continue;
100
+ }
101
+
102
+ if (child.name === name) {
103
+ return child;
104
+ }
105
+ }
106
+ return null;
107
+ }
108
+
109
+ /**
110
+ * Get all the unique groups in the token group, including this group
111
+ * @returns {Array<TokenGroup>}
112
+ */
113
+ getTokenGroups() {
114
+ const set = new Set();
115
+
116
+ for (const child of this) {
117
+ if (child.kind !== 'TokenGroup') {
118
+ continue;
119
+ }
120
+ set.add(child);
121
+ }
122
+
123
+ return Array.from(set);
124
+ }
125
+
126
+ /**
127
+ * Get all the unique properties in the token group, including this group
128
+ * @returns {Array<string>}
129
+ */
130
+ getTokenProperties() {
131
+ const set = new Set();
132
+
133
+ for (const child of this) {
134
+ if (!Array.isArray(child.properties)) {
135
+ continue;
136
+ }
137
+
138
+ for (const property of child.properties) {
139
+ set.add(property);
140
+ }
141
+ }
142
+
143
+ return Array.from(set);
144
+ }
145
+
146
+ /**
147
+ * Get all the unique states in the token group, including this group
148
+ * @returns {Array<string>}
149
+ */
150
+ getTokenStates() {
151
+ const set = new Set();
152
+
153
+ for (const child of this) {
154
+ if (child.kind !== 'Token') {
155
+ continue;
156
+ }
157
+ if (child.state) {
158
+ set.add(child.state);
159
+ }
160
+ }
161
+
162
+ return Array.from(set);
163
+ }
164
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Copyright OctaviaFlow
3
+ * Author: Vishal Kumar
4
+ * Created: 11/November/2025
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ /**
12
+ * A token set is a collection of tokens which should be along with each other.
13
+ * For example, we have tokens that correspond to a layer level in a UI. A
14
+ * token set allows us to group these tokens together in a way that's different
15
+ * than their token group.
16
+ */
17
+ export class TokenSet {
18
+ static create({ name, tokens }) {
19
+ return new TokenSet(name, tokens);
20
+ }
21
+
22
+ constructor(name, tokens = []) {
23
+ this.kind = 'TokenSet';
24
+ this.name = name;
25
+ this.children = tokens;
26
+ }
27
+
28
+ *[Symbol.iterator]() {
29
+ for (const child of this.children) {
30
+ yield child;
31
+
32
+ if (child.kind === 'TokenSet') {
33
+ yield* child;
34
+ }
35
+ }
36
+ }
37
+
38
+ getTokenSets() {
39
+ const children = this.children
40
+ .filter((child) => {
41
+ return child.kind === 'TokenSet';
42
+ })
43
+ .flatMap((child) => {
44
+ return child.getTokenSets();
45
+ });
46
+
47
+ return [this, ...children];
48
+ }
49
+
50
+ getTokenSet(name) {
51
+ for (const child of this) {
52
+ if (!child.kind === 'TokenSet') {
53
+ continue;
54
+ }
55
+
56
+ if (child.name === name) {
57
+ return child;
58
+ }
59
+ }
60
+
61
+ return null;
62
+ }
63
+
64
+ hasToken(tokenOrName) {
65
+ const name =
66
+ typeof tokenOrName === 'string' ? tokenOrName : tokenOrName.name;
67
+
68
+ for (const child of this) {
69
+ if (child.kind === 'TokenSet') {
70
+ continue;
71
+ }
72
+
73
+ if (child.name === name) {
74
+ return true;
75
+ }
76
+ }
77
+
78
+ return false;
79
+ }
80
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Copyright OctaviaFlow
3
+ * Author: Vishal Kumar
4
+ * Created: 11/November/2025
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ import { TokenGroup } from './TokenGroup';
12
+
13
+ export const button = TokenGroup.create({
14
+ name: 'Button',
15
+ properties: [],
16
+ tokens: [
17
+ 'button-separator',
18
+ 'button-primary',
19
+ 'button-secondary',
20
+ 'button-tertiary',
21
+ 'button-danger-primary',
22
+ 'button-danger-secondary',
23
+ 'button-danger-active',
24
+ 'button-primary-active',
25
+ 'button-secondary-active',
26
+ 'button-tertiary-active',
27
+ 'button-danger-hover',
28
+ 'button-primary-hover',
29
+ 'button-secondary-hover',
30
+ 'button-tertiary-hover',
31
+ 'button-disabled',
32
+ ],
33
+ });
34
+
35
+ export const notification = TokenGroup.create({
36
+ name: 'Notification',
37
+ properties: [],
38
+ tokens: [
39
+ 'notification-background-error',
40
+ 'notification-background-success',
41
+ 'notification-background-info',
42
+ 'notification-background-warning',
43
+ 'notification-action-hover',
44
+ 'notification-action-tertiary-inverse',
45
+ 'notification-action-tertiary-inverse-active',
46
+ 'notification-action-tertiary-inverse-hover',
47
+ 'notification-action-tertiary-inverse-text',
48
+ 'notification-action-tertiary-inverse-text-on-color-disabled',
49
+ ],
50
+ });
51
+
52
+ export const tag = TokenGroup.create({
53
+ name: 'Tag',
54
+ properties: [],
55
+ tokens: [
56
+ 'tag-background-red',
57
+ 'tag-color-red',
58
+ 'tag-hover-red',
59
+ 'tag-background-magenta',
60
+ 'tag-color-magenta',
61
+ 'tag-hover-magenta',
62
+ 'tag-background-purple',
63
+ 'tag-color-purple',
64
+ 'tag-hover-purple',
65
+ 'tag-background-blue',
66
+ 'tag-color-blue',
67
+ 'tag-hover-blue',
68
+ 'tag-background-cyan',
69
+ 'tag-color-cyan',
70
+ 'tag-hover-cyan',
71
+ 'tag-background-teal',
72
+ 'tag-color-teal',
73
+ 'tag-hover-teal',
74
+ 'tag-background-green',
75
+ 'tag-color-green',
76
+ 'tag-hover-green',
77
+ 'tag-background-gray',
78
+ 'tag-color-gray',
79
+ 'tag-hover-gray',
80
+ 'tag-border-red',
81
+ 'tag-border-blue',
82
+ 'tag-border-cyan',
83
+ 'tag-border-teal',
84
+ 'tag-border-green',
85
+ 'tag-border-magenta',
86
+ 'tag-border-purple',
87
+ 'tag-border-gray',
88
+ 'tag-border-cool-gray',
89
+ 'tag-border-warm-gray',
90
+ 'tag-background-cool-gray',
91
+ 'tag-color-cool-gray',
92
+ 'tag-hover-cool-gray',
93
+ 'tag-background-warm-gray',
94
+ 'tag-color-warm-gray',
95
+ 'tag-hover-warm-gray',
96
+ ],
97
+ });
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright OctaviaFlow
3
+ * Author: Vishal Kumar
4
+ * Created: 11/November/2025
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ import { Token } from './Token';
12
+ import { TokenFormat } from './TokenFormat';
13
+ import { TokenGroup } from './TokenGroup';
14
+ import { TokenSet } from './TokenSet';
15
+ import { group, contextual } from './v11TokenGroup';
16
+ import { set } from './v11TokenSet';
17
+ import * as components from './components';
18
+ import { type } from './type';
19
+ import { layout } from './layout';
20
+ import { v10 } from './v10';
21
+
22
+ export { Token, TokenFormat, TokenGroup, TokenSet, group, set };
23
+
24
+ const v11 = [
25
+ // Base color tokens
26
+ ...group.getTokens().map((token) => {
27
+ return {
28
+ name: token.name,
29
+ type: 'color',
30
+ };
31
+ }),
32
+
33
+ // Contextual tokens
34
+ ...contextual.getTokens().map((token) => {
35
+ return {
36
+ name: token.name,
37
+ type: 'color',
38
+ };
39
+ }),
40
+
41
+ // Component tokens
42
+ ...Object.values(components).flatMap((group) => {
43
+ return group.getTokens().map((token) => {
44
+ return {
45
+ name: token.name,
46
+ type: 'color',
47
+ };
48
+ });
49
+ }),
50
+
51
+ // Typography
52
+ ...type.getTokens().map((token) => {
53
+ return {
54
+ name: token.name,
55
+ type: 'type',
56
+ };
57
+ }),
58
+
59
+ // Layout (spacing)
60
+ ...layout.getTokens().map((token) => {
61
+ return {
62
+ name: token.name,
63
+ type: 'layout',
64
+ };
65
+ }),
66
+ ];
67
+
68
+ export const unstable_metadata = {
69
+ v11,
70
+ v10,
71
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright OctaviaFlow
3
+ * Author: Vishal Kumar
4
+ * Created: 11/November/2025
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ import { TokenGroup } from './TokenGroup';
12
+
13
+ export const layout = TokenGroup.create({
14
+ name: 'Layout',
15
+ properties: [],
16
+ tokens: [
17
+ 'spacing-01',
18
+ 'spacing-02',
19
+ 'spacing-03',
20
+ 'spacing-04',
21
+ 'spacing-05',
22
+ 'spacing-06',
23
+ 'spacing-07',
24
+ 'spacing-08',
25
+ 'spacing-09',
26
+ 'spacing-10',
27
+ 'spacing-11',
28
+ 'spacing-12',
29
+ 'spacing-13',
30
+ 'fluid-spacing-01',
31
+ 'fluid-spacing-02',
32
+ 'fluid-spacing-03',
33
+ 'fluid-spacing-04',
34
+ 'container-01',
35
+ 'container-02',
36
+ 'container-03',
37
+ 'container-04',
38
+ 'container-05',
39
+ 'icon-size-01',
40
+ 'icon-size-02',
41
+ ],
42
+ });
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright OctaviaFlow
3
+ * Author: Vishal Kumar
4
+ * Created: 11/November/2025
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ import { TokenGroup } from './TokenGroup';
12
+
13
+ export const type = TokenGroup.create({
14
+ name: 'Type',
15
+ properties: [],
16
+ tokens: [
17
+ 'caption-01',
18
+ 'caption-02',
19
+ 'label-01',
20
+ 'label-02',
21
+ 'helper-text-01',
22
+ 'helper-text-02',
23
+ 'body-short-01',
24
+ 'body-long-01',
25
+ 'body-short-02',
26
+ 'body-long-02',
27
+ 'code-01',
28
+ 'code-02',
29
+ 'heading-01',
30
+ 'productive-heading-01',
31
+ 'heading-02',
32
+ 'productive-Heading-02',
33
+ 'productive-heading-03',
34
+ 'productive-heading-04',
35
+ 'productive-heading-05',
36
+ 'productive-heading-06',
37
+ 'productive-heading-07',
38
+ 'expressive-heading-01',
39
+ 'expressive-heading-02',
40
+ 'expressive-heading-03',
41
+ 'expressive-heading-04',
42
+ 'expressive-heading-05',
43
+ 'expressive-heading-06',
44
+ 'expressive-paragraph-01',
45
+ 'quotation-01',
46
+ 'quotation-02',
47
+ 'display-01',
48
+ 'display-02',
49
+ 'display-03',
50
+ 'display-04',
51
+ ],
52
+ });