Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor component-schemas into package #353

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
acb7cc0
chore: refactor component-schemas into package
karstens Jun 7, 2024
5946a63
fix: used correct parameter in schema getFile function
GarthDB Jun 13, 2024
0e882f5
ci: testing automated snapshot release
GarthDB Jun 3, 2024
4b8d625
fix: addressed spectrum-component-api-schemas package name
GarthDB Jun 13, 2024
cdd1511
ci: refactored moon tasks for schema pacakge
GarthDB Jun 13, 2024
6ff5ad7
chore: added changeset
GarthDB Jun 13, 2024
0727a14
chore: snapshot release schema
GarthDB Jun 13, 2024
58dfd16
test: added tests to index.js file
GarthDB Jun 14, 2024
9805167
chore: added changeset
GarthDB Jun 14, 2024
c85b576
chore: snapshot release schema
GarthDB Jun 14, 2024
8017382
ci: fixed snapshot release workflow
GarthDB Jun 15, 2024
f4ec282
refactor: changed getAllSchemas format to include component slugs
GarthDB Jun 15, 2024
9034673
refactor: removed unused component-size type
GarthDB Jun 15, 2024
7a42c4d
feat: initial release
GarthDB Jun 18, 2024
b5c1579
chore: added changeset
GarthDB Jun 18, 2024
3bbc12b
chore: snapshot release schema
GarthDB Jun 18, 2024
8d4e05b
feat: added missing search-field schema
GarthDB Jun 18, 2024
c2cfa56
fix: schema path checks
karstens Jun 18, 2024
ebe6186
test: resolved some absolute path bugs in the tests
GarthDB Jun 20, 2024
64379eb
chore: added changeset
GarthDB Jun 20, 2024
d3c609f
chore: snapshot release schema
GarthDB Jun 20, 2024
672d2d0
fix: tabs and tab-item jsonSchema
karstens Aug 20, 2024
93b6799
fix: size property for action-button jsonSchema
karstens Aug 20, 2024
dfd67f5
fix: image property for avatar jsonSchema
karstens Aug 20, 2024
f1ac034
fix: static color property description
karstens Aug 20, 2024
e08891d
fix: integer as property value type
karstens Aug 20, 2024
0787706
Merge branch 'main' into karstens/DTT-2140--component-api-schemas
karstens Aug 20, 2024
fdb7cf6
fix: pnpm-lock.yaml
karstens Aug 20, 2024
2811d29
fix: add tab-item as children to tabs json schema
karstens Aug 20, 2024
1f2fc6d
fix: run build to publish changed json schemas to docs/site/public
karstens Aug 21, 2024
13ce53a
fix: remove children from tabs.json and remove tab-item-json
karstens Aug 21, 2024
dc2d6c6
chore: added changeset
GarthDB Aug 21, 2024
cf73cf1
chore: snapshot release schema
GarthDB Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions .github/workflows/release-snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,52 @@
name: Release Snapshot

on: workflow_dispatch
on:
workflow_dispatch:
inputs:
tag:
description: "Tag used on changeset version and NPM package"
required: false
type: string

jobs:
get-snapshot-tag:
name: Split branch name
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- id: split
- name: Split branch name
id: split
env:
BRANCH: ${{ github.ref_name }}
run: echo "::set-output name=fragment::${BRANCH##*/}"
run: echo "fragment=${BRANCH##*snapshot-}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get last author info
id: author
run: |
echo "authorName=$(git log -1 --pretty=format:'%an')" >> $GITHUB_OUTPUT
echo "authorEmail=$(git log -1 --pretty=format:'%ae')" >> $GITHUB_OUTPUT
- uses: moonrepo/setup-toolchain@v0
with:
auto-install: true
- run: moon setup
- run: moon run :build --query "projectSource~packages/*"
- name: Snapshot release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
SNAPSHOT_TAG: ${{ inputs.tag || steps.split.outputs.fragment }}
USERNAME: ${{ steps.author.outputs.authorName }}
EMAIL: ${{ steps.author.outputs.authorEmail }}
run: |
pnpm changeset version --snapshot $SNAPSHOT_TAG
git config --global user.name "$USERNAME"
git config --global user.email "$EMAIL"
git add .
git commit -m "chore: snapshot release $SNAPSHOT_TAG"
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
pnpm changeset publish --tag $SNAPSHOT_TAG
git push origin HEAD
git push origin --tags
1 change: 1 addition & 0 deletions .moon/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
$schema: "https://moonrepo.dev/schemas/workspace.json"
projects:
tokens: "packages/tokens"
componentSchemas: "packages/component-schemas"
visualizer: "docs/visualizer"
site: "docs/site"
root: "."
Expand Down
10 changes: 9 additions & 1 deletion docs/site/lib/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,16 @@ export async function getAllComponentSlugs() {
}

export async function getComponentData(slug) {
// not sure, if this should use the public/schemas folder, like getAllComponentSlugs()
const schemaDir = path.resolve(
path.join(process.cwd(), "..", "..", "packages", "tokens", "schemas"),
path.join(
process.cwd(),
"..",
"..",
"packages",
"component-schemas",
"schemas",
),
);
const file = await readJSON(
path.join(schemaDir, "components", `${slug}.json`),
Expand Down
16 changes: 14 additions & 2 deletions docs/site/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ fileGroups:
target:
- "/site/[!visualizer]"
tasks:
copySchema:
copyComponentSchema:
command:
- cp
- -r
- ../../packages/component-schemas/schemas
- public/
platform: system
inputs:
- /packages/component-schemas/schemas/**/*.json
outputs:
- public/schemas
copyTokenTypeSchema:
command:
- cp
- -r
Expand All @@ -33,7 +44,8 @@ tasks:
- build
platform: node
deps:
- ~:copySchema
- ~:copyComponentSchema
- ~:copyTokenTypeSchema
outputs:
- "/site/"
clean:
Expand Down
8 changes: 4 additions & 4 deletions docs/site/public/schemas/components/action-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
},
"size": {
"type": "string",
"enum": ["s", "m", "l", "xl"],
"default": "m",
"pattern": "^(x?s|m|x{0,3}l)$"
"enum": ["xs", "s", "m", "l", "xl"],
"default": "m"
},
"isQuiet": {
"type": "boolean",
Expand All @@ -40,7 +39,8 @@
},
"staticColor": {
"type": "string",
"enum": ["white", "black"]
"enum": ["white", "black"],
"description": "Static color must not be set for the default version of this component."
},
"selectedTextColor": {
"$ref": "https://opensource.adobe.com/spectrum-tokens/schemas/types/hex-color.json"
Expand Down
4 changes: 3 additions & 1 deletion docs/site/public/schemas/components/avatar.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"default": 100
},
"image": {
"type": "string"
"type": "string",
"enum": ["text", "image"],
"default": "image"
},
"isDisabled": {
"type": "boolean",
Expand Down
3 changes: 2 additions & 1 deletion docs/site/public/schemas/components/button.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
},
"staticColor": {
"type": "string",
"enum": ["white", "black"]
"enum": ["white", "black"],
"description": "Static color must not be set for the default version of this component."
},
"style": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion docs/site/public/schemas/components/close-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"staticColor": {
"type": "string",
"enum": ["white", "black"],
"default": null
"description": "Static color must not be set for the default version of this component."
},
"isDisabled": {
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion docs/site/public/schemas/components/link.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"staticColor": {
"type": "string",
"enum": ["white", "black"],
"default": null
"description": "Static color must not be set for the default version of this component."
},
"state": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion docs/site/public/schemas/components/popover.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "object",
"properties": {
"width": {
"type": "integer"
"type": "number"
},
"height": {
"type": "number"
Expand Down
7 changes: 4 additions & 3 deletions docs/site/public/schemas/components/rating.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"type": "object",
"properties": {
"value": {
"type": "integer",
"minimum": 0,
"maximum": 5
"type": "number",
"enum": [0, 1, 2, 3, 4, 5],
"default": 0,
"description": "From 0 to 5"
},
"isEmphasized": {
"type": "boolean",
Expand Down
50 changes: 50 additions & 0 deletions docs/site/public/schemas/components/search-field.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/component.json",
"$id": "https://opensource.adobe.com/spectrum-tokens/schemas/components/search-field.json",
"title": "Search field",
"description": "A search field is used for searching and filtering items.",
"meta": {
"category": "inputs",
"documentationUrl": "https://spectrum.adobe.com/page/search-field/"
},
"type": "object",
"properties": {
"label": {
"type": "string"
},
"value": {
"type": "string"
},
"width": {
"type": "number"
},
"size": {
"type": "string",
"enum": ["s", "m", "l", "xl"],
"default": "m",
"pattern": "^(x?s|m|x{0,3}l)$"
},
"isQuiet": {
"type": "boolean",
"default": false
},
"isDisabled": {
"type": "boolean",
"default": false
},
"description": {
"type": "string"
},
"state": {
"type": "string",
"enum": [
"default",
"hover",
"focus + hover",
"focus + not hover",
"keyboard focus"
],
"default": "default"
}
}
}
40 changes: 31 additions & 9 deletions docs/site/public/schemas/components/tabs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,46 @@
},
"type": "object",
"properties": {
"label": {
"type": "string"
"orientation": {
"type": "string",
"enum": ["horizontal", "vertical"],
"default": "vertical"
},
"icon": {
"$ref": "https://opensource.adobe.com/spectrum-tokens/schemas/types/workflow-icon.json"
"size": {
"type": "string",
"enum": ["s", "m", "l", "xl"],
"default": "m"
},
"isSelected": {
"density": {
"type": "string",
"enum": ["compact", "regular"],
"default": "regular"
},
"isFluid": {
"type": "boolean",
"default": false,
"description": "This overrides density and is only applicable to horizontal tabs."
},
"isQuiet": {
"type": "boolean",
"default": false
},
"isDisabled": {
"isEmphasized": {
"type": "boolean",
"default": false
},
"state": {
"alignment": {
"type": "string",
"enum": ["start", "center"],
"default": "start"
},
"selectedItem": {
"description": "(list of available items)"
},
"keyboardActivation": {
"type": "string",
"enum": ["default", "hover", "down", "keyboard focus"],
"default": "default"
"enum": ["manual", "automatic"],
"default": "manual"
}
}
}
31 changes: 31 additions & 0 deletions packages/component-schemas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# @adobe/spectrum-component-api-schemas

## 0.0.0-schema-20240821152525

### Patch Changes

- [#353](https://github.com/adobe/spectrum-tokens/pull/353) [`dc2d6c6`](https://github.com/adobe/spectrum-tokens/commit/dc2d6c6e12c1ea4fdc0d891b3fd50ea0b1697dd7) Thanks [@karstens](https://github.com/karstens)! - Making adjustments to bring the schema more in line with what was on the spectrum website.

## 0.0.0-schema-20240620220450

### Minor Changes

- [#353](https://github.com/adobe/spectrum-tokens/pull/353) [`64379eb`](https://github.com/adobe/spectrum-tokens/commit/64379ebeaf9402fe77ca1adfd020f42df60c60d9) Thanks [@karstens](https://github.com/karstens)! - Added schema for search-field and fixed some path bugs in testing

## 0.0.0-schema-20240618053842

### Minor Changes

- [#353](https://github.com/adobe/spectrum-tokens/pull/353) [`b5c1579`](https://github.com/adobe/spectrum-tokens/commit/b5c15792ec5f5e5c269bfa7bf58af3df42e648c1) Thanks [@karstens](https://github.com/karstens)! - Initial release

## 0.0.0-schema-20240614194147

### Patch Changes

- [#353](https://github.com/adobe/spectrum-tokens/pull/353) [`9805167`](https://github.com/adobe/spectrum-tokens/commit/980516791c0bef9e2f0bbeffe6515f103f3ad7a2) Thanks [@karstens](https://github.com/karstens)! - fixed some bugs

## 0.0.0-schema-20240613154750

### Patch Changes

- [#353](https://github.com/adobe/spectrum-tokens/pull/353) [`6ff5ad7`](https://github.com/adobe/spectrum-tokens/commit/6ff5ad7a75356f4b93d07a2818b357da19ce5b4b) Thanks [@karstens](https://github.com/karstens)! - Initial release
42 changes: 42 additions & 0 deletions packages/component-schemas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Spectrum Component Schemas

An NPM package of JSON Schema for Spectrum components. Used in the table of options on the Spectrum Design System website (example).

| **Property** | **Values** | **Default value** |
| ------------------- | --------------------------------------- | ----------------- |
| label | text | - |
| hide label | yes / no | no |
| icon | icon / nothing | nothing |
| size | s / m / l / xl | m |
| is quiet | yes / no | no |
| is selected | yes / no | no |
| is emphasized | yes / no | no |
| static color | white / black | none |
| selected text color | hex value | #000000 |
| has hold icon | yes / no | no |
| is disabled | yes / no | no |
| state | default / hover / down / keyboard focus | default |

## Helper functions

- `schemaFileNames`
- `getSchemaFile()`
- `getAllSchemas()`
- `getAllSlugs()`

## Project file structure

```
├── schemas
│ ├── components
│ │ └── // component json files
│ ├── types
│ │ └── // shared types like hex-color
├── test
│ └── // tests
├── CHANGELOG.md // generated by changeset
├── index.js // helpful functions for fetching the schema file data
├── moon.yml // config file for moon monorepo task management
├── package.json
└── README.md // this file!
```
Loading