@oneli8/core 1.0.0-beta.3
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 +202 -0
- package/NOTICE +8 -0
- package/README.md +76 -0
- package/package.json +79 -0
- package/src/atoms/icon/icon.css +54 -0
- package/src/atoms/icon/icon.d.ts +19 -0
- package/src/atoms/icon/icon.js +81 -0
- package/src/atoms/icon/icons.generated.d.ts +38 -0
- package/src/atoms/icon/icons.generated.js +128 -0
- package/src/atoms/icon/index.d.ts +2 -0
- package/src/atoms/icon/index.js +2 -0
- package/src/atoms/index.d.ts +2 -0
- package/src/atoms/index.js +2 -0
- package/src/atoms/selection-indicator/index.d.ts +1 -0
- package/src/atoms/selection-indicator/index.js +1 -0
- package/src/atoms/selection-indicator/selection-indicator.css +140 -0
- package/src/atoms/selection-indicator/selection-indicator.d.ts +36 -0
- package/src/atoms/selection-indicator/selection-indicator.js +61 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +3 -0
- package/src/materials/gem/gem.css +171 -0
- package/src/molecules/button/button.css +193 -0
- package/src/molecules/button/button.d.ts +51 -0
- package/src/molecules/button/button.js +134 -0
- package/src/molecules/button/index.d.ts +1 -0
- package/src/molecules/button/index.js +1 -0
- package/src/molecules/choice-item/choice-item.css +190 -0
- package/src/molecules/choice-item/choice-item.d.ts +54 -0
- package/src/molecules/choice-item/choice-item.js +153 -0
- package/src/molecules/choice-item/index.d.ts +1 -0
- package/src/molecules/choice-item/index.js +1 -0
- package/src/molecules/icon-button/icon-button.css +222 -0
- package/src/molecules/icon-button/icon-button.d.ts +40 -0
- package/src/molecules/icon-button/icon-button.js +121 -0
- package/src/molecules/icon-button/index.d.ts +1 -0
- package/src/molecules/icon-button/index.js +1 -0
- package/src/molecules/index.d.ts +4 -0
- package/src/molecules/index.js +4 -0
- package/src/molecules/selection-option/index.d.ts +1 -0
- package/src/molecules/selection-option/index.js +1 -0
- package/src/molecules/selection-option/selection-option.css +121 -0
- package/src/molecules/selection-option/selection-option.d.ts +42 -0
- package/src/molecules/selection-option/selection-option.js +97 -0
- package/src/organisms/choice-group/choice-group.css +93 -0
- package/src/organisms/choice-group/choice-group.d.ts +80 -0
- package/src/organisms/choice-group/choice-group.js +159 -0
- package/src/organisms/choice-group/index.d.ts +1 -0
- package/src/organisms/choice-group/index.js +1 -0
- package/src/organisms/index.d.ts +1 -0
- package/src/organisms/index.js +1 -0
- package/styles.css +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
OneLi8 Design System (One-Li8)
|
|
2
|
+
Copyright 2026 Akshay Dhore
|
|
3
|
+
|
|
4
|
+
Created by Akshay Dhore. Includes OneLi8's Gem Morphism material treatment.
|
|
5
|
+
Inspired by Guruji Shrii Arnav and the 9x12 Way.
|
|
6
|
+
|
|
7
|
+
This product is licensed under the Apache License, Version 2.0.
|
|
8
|
+
These attribution notices are informational and do not modify the license.
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @oneli8/core
|
|
2
|
+
|
|
3
|
+
OneLi8 Design System — framework-agnostic components.
|
|
4
|
+
|
|
5
|
+
Every component is two functions: `renderX(...)` returns an HTML **string**, and
|
|
6
|
+
`hydrateX(root)` enforces the runtime contract on markup that already exists.
|
|
7
|
+
There is no framework dependency, no virtual DOM and no build step.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @oneli8/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { renderButton, hydrateButtons } from '@oneli8/core';
|
|
15
|
+
import '@oneli8/core/styles.css';
|
|
16
|
+
|
|
17
|
+
document.querySelector('#toolbar').innerHTML = renderButton('Save', {
|
|
18
|
+
variant: 'primary',
|
|
19
|
+
leadingIcon: 'add',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
hydrateButtons();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## What is included
|
|
26
|
+
|
|
27
|
+
| Tier | Component |
|
|
28
|
+
|---|---|
|
|
29
|
+
| Atom | `Icon`, `Selection Indicator` (checkbox, radio, switch) |
|
|
30
|
+
| Molecule | `Button`, `Icon Button`, `Choice Item`, `Selection Option` |
|
|
31
|
+
| Organism | `Choice Group` (checkbox hierarchy, radio group) |
|
|
32
|
+
| Material | `Gem` — an attribute adapter, not a tier |
|
|
33
|
+
|
|
34
|
+
Anything not listed is not exported. Tokens exist for component families whose
|
|
35
|
+
implementations are not in this release; a token is not a promise of a component.
|
|
36
|
+
|
|
37
|
+
## Rendering and hydration
|
|
38
|
+
|
|
39
|
+
`render*` covers everything expressible in markup. `hydrate*` exists only for
|
|
40
|
+
what markup genuinely cannot express:
|
|
41
|
+
|
|
42
|
+
- `indeterminate` on a checkbox is a JavaScript-only property, so Mixed needs
|
|
43
|
+
hydration and every other state does not.
|
|
44
|
+
- A `<button>` without an explicit `type` submits its form. Hydration pins it.
|
|
45
|
+
- Links cannot be natively disabled, so they get `aria-disabled` and their
|
|
46
|
+
activation is swallowed.
|
|
47
|
+
|
|
48
|
+
Hydration is idempotent — running it twice changes nothing.
|
|
49
|
+
|
|
50
|
+
## Styles
|
|
51
|
+
|
|
52
|
+
`@oneli8/core/styles.css` pulls in the tokens and every component sheet in the
|
|
53
|
+
order they must load. To take only what you use, import the parts:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import '@oneli8/tokens/css';
|
|
57
|
+
import '@oneli8/core/styles/button.css';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Tokens must always come first — every component rule reads them.
|
|
61
|
+
|
|
62
|
+
## Accessibility is enforced, not suggested
|
|
63
|
+
|
|
64
|
+
`renderIconButton` throws without an accessible name. `renderButton` throws for
|
|
65
|
+
`material: "gem"` on `quiet` or `destructive`, because Figma approves Gem for
|
|
66
|
+
Primary and Secondary only. These are errors rather than review comments on
|
|
67
|
+
purpose.
|
|
68
|
+
|
|
69
|
+
Test Gem against its real backdrop. Near-white content alone does not guarantee
|
|
70
|
+
readable contrast.
|
|
71
|
+
|
|
72
|
+
## Licence
|
|
73
|
+
|
|
74
|
+
Apache-2.0. Created by Akshay Dhore. See `LICENSE` and `NOTICE`; preserve the
|
|
75
|
+
attribution notices when redistributing. This does not require a visible badge
|
|
76
|
+
in your product, and implies no OneLi8 endorsement.
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oneli8/core",
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
|
+
"description": "OneLi8 Design System \u2014 framework-agnostic components. Renders HTML strings and hydrates existing DOM; no framework required.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"design-system",
|
|
7
|
+
"components",
|
|
8
|
+
"headless",
|
|
9
|
+
"framework-agnostic",
|
|
10
|
+
"design-tokens",
|
|
11
|
+
"accessibility",
|
|
12
|
+
"oneli8"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/Akshay007ad/OneLi8-Design-System#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Akshay007ad/OneLi8-Design-System/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/Akshay007ad/OneLi8-Design-System.git",
|
|
21
|
+
"directory": "packages/core"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"author": "Akshay Dhore",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./src/index.d.ts",
|
|
29
|
+
"import": "./src/index.js",
|
|
30
|
+
"default": "./src/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./atoms": {
|
|
33
|
+
"types": "./src/atoms/index.d.ts",
|
|
34
|
+
"import": "./src/atoms/index.js",
|
|
35
|
+
"default": "./src/atoms/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./molecules": {
|
|
38
|
+
"types": "./src/molecules/index.d.ts",
|
|
39
|
+
"import": "./src/molecules/index.js",
|
|
40
|
+
"default": "./src/molecules/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./organisms": {
|
|
43
|
+
"types": "./src/organisms/index.d.ts",
|
|
44
|
+
"import": "./src/organisms/index.js",
|
|
45
|
+
"default": "./src/organisms/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./styles.css": "./styles.css",
|
|
48
|
+
"./styles/icon.css": "./src/atoms/icon/icon.css",
|
|
49
|
+
"./styles/selection-indicator.css": "./src/atoms/selection-indicator/selection-indicator.css",
|
|
50
|
+
"./styles/button.css": "./src/molecules/button/button.css",
|
|
51
|
+
"./styles/icon-button.css": "./src/molecules/icon-button/icon-button.css",
|
|
52
|
+
"./styles/choice-item.css": "./src/molecules/choice-item/choice-item.css",
|
|
53
|
+
"./styles/selection-option.css": "./src/molecules/selection-option/selection-option.css",
|
|
54
|
+
"./styles/choice-group.css": "./src/organisms/choice-group/choice-group.css",
|
|
55
|
+
"./styles/gem.css": "./src/materials/gem/gem.css",
|
|
56
|
+
"./package.json": "./package.json"
|
|
57
|
+
},
|
|
58
|
+
"types": "./src/index.d.ts",
|
|
59
|
+
"sideEffects": [
|
|
60
|
+
"./styles.css",
|
|
61
|
+
"**/*.css"
|
|
62
|
+
],
|
|
63
|
+
"files": [
|
|
64
|
+
"src",
|
|
65
|
+
"styles.css",
|
|
66
|
+
"README.md",
|
|
67
|
+
"LICENSE",
|
|
68
|
+
"NOTICE"
|
|
69
|
+
],
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@oneli8/tokens": "1.0.0-beta.3"
|
|
72
|
+
},
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": ">=20"
|
|
75
|
+
},
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oneli8 · Icon atom
|
|
3
|
+
* Figma: page "Iconography" — masters "Icon Library / Masters" (426:55),
|
|
4
|
+
* sizing from "Icon Frame" (418:51).
|
|
5
|
+
*
|
|
6
|
+
* Contract, straight from the Figma component descriptions:
|
|
7
|
+
* - one canonical 24px source per glyph
|
|
8
|
+
* - the Icon Frame *geometrically* scales the complete source instance, so
|
|
9
|
+
* the 1.8-unit stroke scales with the artwork (48px icon => 3.6px stroke).
|
|
10
|
+
* This is why the SVG keeps viewBox="0 0 24 24" and we size the box only —
|
|
11
|
+
* never `vector-effect: non-scaling-stroke`.
|
|
12
|
+
* - the source is neutral; the consumer supplies semantic color, which is
|
|
13
|
+
* why every stroke/fill is `currentColor`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
.ol8-icon {
|
|
17
|
+
/* The outer asset box. Defaults to the canonical 24px source size. */
|
|
18
|
+
--_ol8-icon-size: var(--ol8-icon-size-024);
|
|
19
|
+
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
flex: none;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
inline-size: var(--_ol8-icon-size);
|
|
25
|
+
block-size: var(--_ol8-icon-size);
|
|
26
|
+
/* Inherit ink from the consuming component (semantic color lives there). */
|
|
27
|
+
color: inherit;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* The inner leaf. Both dimensions are explicit — never `auto`. */
|
|
31
|
+
.ol8-icon > svg {
|
|
32
|
+
display: block;
|
|
33
|
+
inline-size: var(--_ol8-icon-size);
|
|
34
|
+
block-size: var(--_ol8-icon-size);
|
|
35
|
+
overflow: visible; /* matches the Figma export; round caps may kiss the edge */
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* ---- Icon Frame · universal sizes (Figma 418:51) ---------------------- */
|
|
39
|
+
.ol8-icon[data-ol8-icon-size="9"] { --_ol8-icon-size: var(--ol8-icon-size-009); }
|
|
40
|
+
.ol8-icon[data-ol8-icon-size="12"] { --_ol8-icon-size: var(--ol8-icon-size-012); }
|
|
41
|
+
.ol8-icon[data-ol8-icon-size="18"] { --_ol8-icon-size: var(--ol8-icon-size-018); }
|
|
42
|
+
.ol8-icon[data-ol8-icon-size="24"] { --_ol8-icon-size: var(--ol8-icon-size-024); }
|
|
43
|
+
.ol8-icon[data-ol8-icon-size="30"] { --_ol8-icon-size: var(--ol8-icon-size-030); }
|
|
44
|
+
.ol8-icon[data-ol8-icon-size="36"] { --_ol8-icon-size: var(--ol8-icon-size-036); }
|
|
45
|
+
.ol8-icon[data-ol8-icon-size="48"] { --_ol8-icon-size: var(--ol8-icon-size-048); }
|
|
46
|
+
.ol8-icon[data-ol8-icon-size="60"] { --_ol8-icon-size: var(--ol8-icon-size-060); }
|
|
47
|
+
.ol8-icon[data-ol8-icon-size="72"] { --_ol8-icon-size: var(--ol8-icon-size-072); }
|
|
48
|
+
.ol8-icon[data-ol8-icon-size="96"] { --_ol8-icon-size: var(--ol8-icon-size-096); }
|
|
49
|
+
.ol8-icon[data-ol8-icon-size="108"] { --_ol8-icon-size: var(--ol8-icon-size-108); }
|
|
50
|
+
|
|
51
|
+
/* ---- Direction ------------------------------------------------------- */
|
|
52
|
+
/* "Direction: semantic registry controls RTL mirroring" (Iconography doc 84:13).
|
|
53
|
+
The registry sets data-ol8-icon-mirror; CSS only obeys it. */
|
|
54
|
+
[dir="rtl"] .ol8-icon[data-ol8-icon-mirror="true"] > svg { transform: scaleX(-1); }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Ol8IconName } from './icons.generated.js';
|
|
2
|
+
|
|
3
|
+
export type Ol8IconSize = 9 | 12 | 18 | 24 | 30 | 36 | 48 | 60 | 72 | 96 | 108;
|
|
4
|
+
export declare const OL8_ICON_SIZES: readonly Ol8IconSize[];
|
|
5
|
+
|
|
6
|
+
export interface Ol8IconOptions {
|
|
7
|
+
/** One of the Icon Frame universal sizes. Defaults to the 24px source size. */
|
|
8
|
+
size?: Ol8IconSize;
|
|
9
|
+
/** Accessible name. Omit for decorative icons (the default). */
|
|
10
|
+
label?: string;
|
|
11
|
+
/** Extra classes on the outer box. */
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare function isOl8IconName(name: string): name is Ol8IconName;
|
|
16
|
+
export declare function renderIconSvg(name: Ol8IconName): string;
|
|
17
|
+
export declare function renderIcon(name: Ol8IconName, options?: Ol8IconOptions): string;
|
|
18
|
+
export declare function hydrateIcons(root?: ParentNode): void;
|
|
19
|
+
export { OL8_ICONS, type Ol8IconName } from './icons.generated.js';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oneli8 · Icon atom — headless behavior.
|
|
3
|
+
*
|
|
4
|
+
* Two entry points, one output:
|
|
5
|
+
* renderIcon(name, opts) -> markup string (build time / SSR)
|
|
6
|
+
* hydrateIcons(root) -> fills in [data-ol8-icon] placeholders (runtime)
|
|
7
|
+
*
|
|
8
|
+
* Icons render INLINE (never <img>) because the Figma contract says the consumer
|
|
9
|
+
* supplies semantic color — that needs `currentColor`, which <img> cannot inherit.
|
|
10
|
+
*/
|
|
11
|
+
import { OL8_ICONS, OL8_ICON_VIEWBOX } from './icons.generated.js';
|
|
12
|
+
|
|
13
|
+
/** Universal sizes from the Figma "Icon Frame" (418:51). */
|
|
14
|
+
export const OL8_ICON_SIZES = [9, 12, 18, 24, 30, 36, 48, 60, 72, 96, 108];
|
|
15
|
+
|
|
16
|
+
/** @param {string} name */
|
|
17
|
+
export function isOl8IconName(name) {
|
|
18
|
+
return Object.hasOwn(OL8_ICONS, name);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The inner leaf only — the <svg>, in canonical 24-unit source space. */
|
|
22
|
+
export function renderIconSvg(name) {
|
|
23
|
+
if (!isOl8IconName(name)) throw new Error(`[ol8] unknown icon "${name}"`);
|
|
24
|
+
return `<svg viewBox="${OL8_ICON_VIEWBOX}" fill="none" focusable="false">${OL8_ICONS[name].body}</svg>`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The complete atom: outer box + leaf. */
|
|
28
|
+
export function renderIcon(name, options = {}) {
|
|
29
|
+
if (!isOl8IconName(name)) throw new Error(`[ol8] unknown icon "${name}"`);
|
|
30
|
+
const { size = 24, label, className } = options;
|
|
31
|
+
if (!OL8_ICON_SIZES.includes(size)) {
|
|
32
|
+
throw new Error(`[ol8] size ${size} is not an Icon Frame universal size (${OL8_ICON_SIZES.join(', ')})`);
|
|
33
|
+
}
|
|
34
|
+
const entry = OL8_ICONS[name];
|
|
35
|
+
const attrs = [
|
|
36
|
+
`class="ol8-icon${className ? ` ${className}` : ''}"`,
|
|
37
|
+
`data-ol8-icon="${name}"`,
|
|
38
|
+
`data-ol8-icon-size="${size}"`,
|
|
39
|
+
entry.mirrorInRTL ? 'data-ol8-icon-mirror="true"' : '',
|
|
40
|
+
label ? `role="img" aria-label="${escapeAttr(label)}"` : 'aria-hidden="true"',
|
|
41
|
+
].filter(Boolean).join(' ');
|
|
42
|
+
return `<span ${attrs}>${renderIconSvg(name)}</span>`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Upgrades every `[data-ol8-icon]` placeholder under `root` in place. Idempotent.
|
|
47
|
+
* <span data-ol8-icon="add" data-ol8-icon-size="18"></span>
|
|
48
|
+
* <span data-ol8-icon="close" data-ol8-icon-label="Dismiss"></span>
|
|
49
|
+
*/
|
|
50
|
+
export function hydrateIcons(root = document) {
|
|
51
|
+
for (const el of root.querySelectorAll('[data-ol8-icon]')) {
|
|
52
|
+
if (el.dataset.ol8IconHydrated === 'true') continue;
|
|
53
|
+
const name = el.dataset.ol8Icon ?? '';
|
|
54
|
+
if (!isOl8IconName(name)) { console.warn(`[ol8] unknown icon "${name}"`, el); continue; }
|
|
55
|
+
|
|
56
|
+
const entry = OL8_ICONS[name];
|
|
57
|
+
const label = el.dataset.ol8IconLabel;
|
|
58
|
+
|
|
59
|
+
el.classList.add('ol8-icon');
|
|
60
|
+
if (!el.dataset.ol8IconSize) el.dataset.ol8IconSize = '24';
|
|
61
|
+
if (entry.mirrorInRTL) el.dataset.ol8IconMirror = 'true';
|
|
62
|
+
|
|
63
|
+
if (label) {
|
|
64
|
+
el.setAttribute('role', 'img');
|
|
65
|
+
el.setAttribute('aria-label', label);
|
|
66
|
+
el.removeAttribute('aria-hidden');
|
|
67
|
+
} else {
|
|
68
|
+
el.setAttribute('aria-hidden', 'true');
|
|
69
|
+
el.removeAttribute('role');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
el.innerHTML = renderIconSvg(name);
|
|
73
|
+
el.dataset.ol8IconHydrated = 'true';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function escapeAttr(value) {
|
|
78
|
+
return String(value).replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { OL8_ICONS };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// GENERATED by packages/sync/src/build-icons.mjs — do not edit by hand.
|
|
2
|
+
// Source: Figma "Oneli8 Design System — 1.0.0-beta.1", page Iconography,
|
|
3
|
+
// frame "Icon Library / Masters" (426:55). Re-run `npm run sync:icons`.
|
|
4
|
+
|
|
5
|
+
export interface Ol8IconEntry {
|
|
6
|
+
/** Figma category segment: "Icon / <Category> / <Name>". */
|
|
7
|
+
readonly category: 'action' | 'navigation' | 'status' | 'selection';
|
|
8
|
+
/** Node id of the 24px master in the Figma source file. */
|
|
9
|
+
readonly figmaNode: string;
|
|
10
|
+
/** Semantic registry controls RTL mirroring (per Iconography documentation). */
|
|
11
|
+
readonly mirrorInRTL: boolean;
|
|
12
|
+
/** The ink Figma baked into the master, discarded in favour of currentColor. */
|
|
13
|
+
readonly sourceInk: string | null;
|
|
14
|
+
/** Drawing instructions in the canonical 24-unit source space. */
|
|
15
|
+
readonly body: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare const OL8_ICON_VIEWBOX: '0 0 24 24';
|
|
19
|
+
export declare const OL8_ICONS: {
|
|
20
|
+
readonly "add": Ol8IconEntry;
|
|
21
|
+
readonly "caution": Ol8IconEntry;
|
|
22
|
+
readonly "check": Ol8IconEntry;
|
|
23
|
+
readonly "chevron-down": Ol8IconEntry;
|
|
24
|
+
readonly "chevron-up": Ol8IconEntry;
|
|
25
|
+
readonly "clear": Ol8IconEntry;
|
|
26
|
+
readonly "close": Ol8IconEntry;
|
|
27
|
+
readonly "critical": Ol8IconEntry;
|
|
28
|
+
readonly "forward": Ol8IconEntry;
|
|
29
|
+
readonly "informative": Ol8IconEntry;
|
|
30
|
+
readonly "loading": Ol8IconEntry;
|
|
31
|
+
readonly "mixed": Ol8IconEntry;
|
|
32
|
+
readonly "positive": Ol8IconEntry;
|
|
33
|
+
readonly "search": Ol8IconEntry;
|
|
34
|
+
readonly "selected-dot": Ol8IconEntry;
|
|
35
|
+
readonly "visibility-closed": Ol8IconEntry;
|
|
36
|
+
readonly "visibility-open": Ol8IconEntry;
|
|
37
|
+
};
|
|
38
|
+
export type Ol8IconName = keyof typeof OL8_ICONS;
|