Skip to content

Commit 471a702

Browse files
committed
feat: new s2 token visualizer added
1 parent a30add7 commit 471a702

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+17687
-0
lines changed

.moon/workspace.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ $schema: "https://moonrepo.dev/schemas/workspace.json"
33
projects:
44
tokens: "packages/tokens"
55
visualizer: "docs/visualizer"
6+
s2-visualizer: "docs/s2-visualizer"
67
site: "docs/site"
78
csvGenerator: tools/token-csv-generator
89
transform-tokens-json: "tools/transform-tokens-json"

docs/s2-visualizer/.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
3+
## npm
4+
/node_modules/
5+
6+
## typescript types
7+
/types/
8+
.DS_Store
9+
.DS_Store

docs/s2-visualizer/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# stvt
2+
3+
## 0.0.1
4+
5+
### Patch Changes
6+
7+
- [#436](https://github.com/adobe/spectrum-tokens/pull/436) [`101e1e1`](https://github.com/adobe/spectrum-tokens/commit/101e1e1d58d75e780334588f69d2f2947e35b776) Thanks [@GarthDB](https://github.com/GarthDB)! - Tokens recently changed to use numbers for certain values (multipliers, etc). This caused a bug in the visualizer.

docs/s2-visualizer/README.md

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Spectrum Token Visualization Tool
2+
3+
Current url of deployed static site: [https://opensource.adobe.com/spectrum-tokens/visualizer/](https://opensource.adobe.com/spectrum-tokens/visualizer/)
4+
5+
<img width="1491" alt="Screenshot 2023-02-28 at 2 40 02 PM" src="https://github.com/adobe/spectrum-tokens/assets/125516/3c57f2de-c42e-41a5-abed-e5da294339f0">
6+
7+
## Setup for local development
8+
9+
First, checkout the source code
10+
11+
```
12+
git clone [email protected]:adobe/spectrum-tokens.git
13+
```
14+
15+
Navigate into the spectrum-token-visualization-tool directory.
16+
17+
```
18+
cd spectrum-tokens/docs/visualizer/
19+
```
20+
21+
Install package dependencies
22+
23+
```
24+
pnpm install
25+
```
26+
27+
Startup the local development webserver
28+
29+
```
30+
pnpm moon run visualizer:dev
31+
```
32+
33+
Now you can edit any project files, and your browser will hot-reload with your changes.
34+
35+
This project is based on the Vite Lit Element Typescript boilerplate static site tooling.
36+
37+
You can read all about Vite here: https://vitejs.dev/guide/
38+
39+
You can read all about Lit Element here: https://lit.dev/docs/api/LitElement/
40+
41+
_LOCAL DEVELOPMENT NOTE_
42+
Because we use web workers to offload some of the data processing, local development must be done in a browser that supports Worker Ecmascript Modules: https://caniuse.com/mdn-api_worker_worker_ecmascript_modules. In other words, you can use Chrome or Safari, but NOT Firefox ( as of 12.15.2022 ). This note applies ONLY to the local development webserver. Firefox does work correctly with the built static site.
43+
44+
## Updating the deployed static site
45+
46+
The static site is hosted from the `/docs` directory of the `main` branch.
47+
48+
Build the static site locally. This will overwrite the contents of the /docs directory in the project.
49+
50+
```
51+
pnpm moon run visualizer:build
52+
```
53+
54+
Commit the updated static site files to the git repo.
55+
56+
```
57+
git add .
58+
59+
git commit -m 'description of changes'
60+
61+
git push
62+
```
63+
64+
## What is this prototype? How does it work?
65+
66+
The Spectrum Tokens source-of-truth is persisted in this public GitHub repo: https://github.com/adobe/spectrum-tokens
67+
68+
Within that repository, the tokens are stored in a series of JSON files: https://github.com/adobe/spectrum-tokens/tree/beta/src
69+
70+
This json data structure models a directed graph of conditional relationships between tokens, meant to represent the dynamic value assignments that Spectrum clients have access to when using particular filter configurations, such as 'Spectrum/Light/Desktop' or 'Express/Darkest/Mobile'.
71+
72+
This tool is a static site single page application that...
73+
74+
- Loads all of these JSON files via XHR requests at runtime
75+
- Converts the token data into a formal node graph
76+
- Has nodes representing Spectrum Tokens, Spectrum Components, and Spectrum Token Categories
77+
- Has adjacencies between nodes derived from the source JSON files
78+
- Renders a dynamic node graph view with zooming and panning
79+
- Permits the user to simultaneously view any set of adjacency/value filters. eg.'Spectrum/Light/Desktop' or 'Express/Light/Dark/Darkest/Desktop/Mobile'
80+
- Permits the user to select any combination of Components, Tokens, and Token Categories
81+
- Permits the user to search for Components, Tokens, and Token Categories by substring OR value
82+
- Displays the expanded Ancestor and Descendent graphs of all selected nodes
83+
- Highlights the connecting token paths between selections
84+
- Highlights the common tokens within overlapping selection descendent graphs

docs/s2-visualizer/index.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/adobe.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>S T V T</title>
8+
<script type="module" src="/src/components/stvt-app.ts"></script>
9+
<script
10+
src="https://use.typekit.net/mge7bvf.js"
11+
type="text/javascript"
12+
async=""
13+
></script>
14+
<style>
15+
html,
16+
body {
17+
margin: 0;
18+
padding: 0;
19+
}
20+
</style>
21+
</head>
22+
<body>
23+
<stvt-app></stvt-app>
24+
</body>
25+
</html>

docs/s2-visualizer/moon.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2025 Adobe. All rights reserved.
2+
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License. You may obtain a copy
4+
# of the License at http://www.apache.org/licenses/LICENSE-2.0
5+
6+
# Unless required by applicable law or agreed to in writing, software distributed under
7+
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8+
# OF ANY KIND, either express or implied. See the License for the specific language
9+
# governing permissions and limitations under the License.
10+
$schema: "https://moonrepo.dev/schemas/project.json"
11+
stack: frontend
12+
type: application
13+
tags:
14+
- docs
15+
- site
16+
fileGroups:
17+
sources:
18+
- "src/**/*"
19+
config:
20+
- "vite.config.ts"
21+
- "tsconfig.json"
22+
- "tsconfig.node.json"
23+
tasks:
24+
build:
25+
command:
26+
- vite
27+
- build
28+
deps:
29+
- ~:typescript
30+
platform: node
31+
inputs:
32+
- "config"
33+
- "@globs(sources)"
34+
outputs:
35+
- "/site/visualizer"
36+
typescript:
37+
command: tsc
38+
platform: node
39+
dev:
40+
command: vite
41+
local: true
42+
platform: node
43+
inputs:
44+
- "config"
45+
- "@globs(sources)"

docs/s2-visualizer/package.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "s2stvt",
3+
"private": true,
4+
"access": "restricted",
5+
"type": "module",
6+
"version": "0.0.1",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/adobe/spectrum-tokens.git"
10+
},
11+
"license": "Apache-2.0",
12+
"bugs": {
13+
"url": "https://github.com/adobe/spectrum-tokens/issues"
14+
},
15+
"homepage": "https://github.com/adobe/spectrum-tokens/tree/main/docs/s2-visualizer#readme",
16+
"devDependencies": {
17+
"@types/node": "^22.7.5",
18+
"typescript": "^5.6.3",
19+
"vite": "^5.4.8"
20+
},
21+
"dependencies": {
22+
"@spectrum-web-components/alert-banner": "^0.48.1",
23+
"@spectrum-web-components/action-button": "^0.48.1",
24+
"@spectrum-web-components/button": "^0.48.1",
25+
"@spectrum-web-components/button-group": "^0.48.1",
26+
"@spectrum-web-components/field-group": "^0.48.1",
27+
"@spectrum-web-components/field-label": "^0.48.1",
28+
"@spectrum-web-components/link": "^0.48.1",
29+
"@spectrum-web-components/overlay": "^0.48.1",
30+
"@spectrum-web-components/popover": "^0.48.1",
31+
"@spectrum-web-components/search": "^0.48.1",
32+
"@spectrum-web-components/slider": "^0.48.1",
33+
"@spectrum-web-components/switch": "^0.48.1",
34+
"@spectrum-web-components/textfield": "^0.48.1",
35+
"@spectrum-web-components/theme": "^0.48.1",
36+
"@spectrum-web-components/toast": "^0.48.1",
37+
"@spectrum-web-components/tooltip": "^0.48.1",
38+
"lit": "^3.2.1"
39+
}
40+
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

docs/s2-visualizer/public/adobe.svg

+13
Loading

0 commit comments

Comments
 (0)