Skip to content

Commit ee9cb78

Browse files
authored
✨ created json-resume web component (#1)
* 🤡 add example package * 📝 adjust repo name * ✅ add chromatic and UI tests
1 parent 7c36cbb commit ee9cb78

22 files changed

+17260
-158
lines changed

.github/workflows/chromatic.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Workflow name
2+
name: 'Chromatic'
3+
4+
# Event for the workflow
5+
on: push
6+
7+
# List of jobs
8+
jobs:
9+
chromatic-deployment:
10+
# Operating System
11+
runs-on: ubuntu-latest
12+
# Job steps
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: '20.x'
21+
- name: Install dependencies
22+
run: yarn install
23+
# 👇 Adds Chromatic as a step in the workflow
24+
- name: Publish to Chromatic
25+
uses: chromaui/action@latest
26+
# Chromatic GitHub Action options
27+
with:
28+
# 👇 Chromatic projectToken, refer to the manage page to obtain it.
29+
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
30+
onlyChanged: true

.github/workflows/ui-tests.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 'UI Tests'
2+
3+
on: push
4+
5+
jobs:
6+
# Run interaction and accessibility tests
7+
interaction-and-accessibility:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-node@v4
12+
with:
13+
node-version: '20.x'
14+
- name: Install dependencies
15+
run: yarn install
16+
- name: Install Playwright
17+
run: npx playwright install --with-deps
18+
- name: Build Storybook
19+
run: npm run build-storybook
20+
- name: Serve Storybook and run tests
21+
run: |
22+
npx --yes concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
23+
"npx --yes http-server ./storybook-static --port 2001 --silent" \
24+
"npx wait-on http://127.0.0.1:2001 && npx test-storybook --url http://127.0.0.1:2001"

.storybook/main.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { StorybookConfig } from '@storybook/web-components-vite'
2+
import path from 'path'
3+
4+
const config: StorybookConfig = {
5+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
6+
addons: [
7+
'@storybook/addon-links',
8+
'@storybook/addon-essentials',
9+
'@storybook/addon-interactions',
10+
'@chromatic-com/storybook',
11+
'storybook-addon-render-modes'
12+
],
13+
framework: {
14+
name: '@storybook/web-components-vite',
15+
options: {},
16+
},
17+
docs: {
18+
autodocs: 'tag',
19+
},
20+
async viteFinal(config, options) {
21+
// Ensures that the cache directory is inside the project directory
22+
config.cacheDir = path.join(__dirname, '../node_modules/.vite-storybook')
23+
config.resolve = {
24+
...config.resolve,
25+
alias: {
26+
'@': path.resolve(__dirname, '../src/'),
27+
},
28+
}
29+
config.define = {
30+
...config.define,
31+
'process.env': process.env,
32+
}
33+
return config
34+
},
35+
}
36+
export default config

.storybook/preview.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import type { Preview } from '@storybook/web-components'
2+
import { setCustomElementsManifest } from "@storybook/web-components";
3+
import { MINIMAL_VIEWPORTS } from '@storybook/addon-viewport';
4+
5+
import customElements from "../custom-elements.json";
6+
7+
setCustomElementsManifest(customElements);
8+
9+
const customViewports = {
10+
minimum: {
11+
name: 'minimum',
12+
styles: {
13+
width: '400px',
14+
height: '100%'
15+
},
16+
},
17+
medium: {
18+
name: 'medium',
19+
styles: {
20+
width: '600px',
21+
height: '100%'
22+
},
23+
},
24+
};
25+
26+
const personSchemaWrapper = content => {
27+
return `<article itemscope itemtype="https://schema.org/Person">${content}</article>`
28+
}
29+
global.psw = personSchemaWrapper
30+
31+
const preview: Preview = {
32+
parameters: {
33+
controls: {
34+
expanded: true,
35+
matchers: {
36+
color: /(background|color)$/i,
37+
date: /Date$/i,
38+
},
39+
},
40+
layout: 'fullscreen',
41+
viewport: {
42+
viewports: {
43+
...MINIMAL_VIEWPORTS,
44+
...customViewports,
45+
},
46+
},
47+
},
48+
}
49+
50+
export default preview

README.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,53 @@
1-
# jsonresume-web-component
1+
# jsonresume-component
22

3-
A web component (using LitElement) which presents resume content stored in [JSON Resume][jsonresume] format. The HTML structure uses the methods in [jsonresume-theme-microdata][jtm] to generate HTML which includes structured data as microdata in HTML attributes.
3+
`<json-resume>` is a web component (using LitElement) which presents resume content stored in [JSON Resume][jsonresume] format. The HTML structure uses the components from [jsonresume-theme-microdata][jtm] to generate HTML which includes structured data as microdata in HTML attributes.
44

5-
## Installation
5+
6+
## NPM / Node.js usage
7+
8+
### Install dependencies
9+
10+
```sh
11+
npm i jsonresume-component
12+
```
613

714
```javascript
8-
npm i jsonresume-web-component
15+
import { JsonResume } from 'jsonresume-component/src/index.js';
16+
```
17+
18+
```html
19+
<JsonResume gist_id="9e7a7ceb9425336c6aa08d58afb63b8d"></JsonResume>
20+
```
21+
22+
## Browser usage
23+
24+
**note:** requires installing `lit` and `@lit/task`.
25+
26+
### Add jsonresume-component and dependencies
27+
28+
```html
29+
<script type="importmap">
30+
{
31+
"imports": {
32+
"lit": "https://esm.run/lit",
33+
"@lit/task": "https://esm.run/@lit/task"
34+
}
35+
}
36+
</script>
37+
<script type="module">
38+
import 'https://esm.run/jsonresume-component'
39+
</script>
40+
```
41+
42+
### Use the web component by giving it your `gist` ID
43+
44+
```html
45+
<json-resume gist_id="9e7a7ceb9425336c6aa08d58afb63b8d"></json-resume>
946
```
1047

1148
## A modified JSON Resume schema
1249

13-
The JSON structure follows an extension of the [JSON Resume][jsonresume] schema with added schema structure for microdata `itemtype` on some content types, `basics.pronouns`, and `meta.sectionTitles` which allows changing the content of the resume section titles. See the [jsonresume-theme-microdata][jtm] README for details on this adjusted structure.
50+
The JSON structure follows an extension of the [JSON Resume][jsonresume] schema with added schema structure for microdata `itemtype` on some content types, `basics.pronouns`, and `meta.themeOptions` which allows changing the content of the resume section titles, colors, and other theme opts. See the [jsonresume-theme-microdata][jtm] README for details on this adjusted structure.
1451

1552

1653
[microdata-html]: /blahg/microdata-with-html/

0 commit comments

Comments
 (0)