Skip to content

Commit debf421

Browse files
authored
🎨 add some themes stories (#12)
* 🎨 add some themes stories * 🐛 disable mode on them stories * 🚀 add addon, adjust modes * 🐛 easier mode disable * 🤡 more examples, update fixtures * 🎨 repo cleanup
1 parent 99a1eb5 commit debf421

Some content is hidden

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

51 files changed

+11112
-2353
lines changed

.storybook/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config = {
99
'@storybook/addon-interactions',
1010
'@storybook/addon-coverage',
1111
'storybook-addon-mock',
12+
'@chromaui/addon-visual-tests',
1213
],
1314
framework: {
1415
name: '@storybook/web-components-vite',

.storybook/modes.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ import { primerThemes } from './primer-preview';
99
const defaultThemes = ['light', 'dark'];
1010

1111
export const defaultModes = {};
12+
export const defaultModesDisabled = {};
1213
export const githubModes = {};
1314

1415
for (const key of Object.keys(customViewports)) {
1516
defaultModes[key] = {
1617
viewport: key,
1718
};
19+
defaultModesDisabled[key] = {
20+
disabled: true,
21+
};
1822
githubModes[key] = {
1923
viewport: key,
2024
};
@@ -23,6 +27,9 @@ for (const key of Object.keys(customViewports)) {
2327
viewport: key,
2428
theme: theme,
2529
};
30+
defaultModesDisabled[`${theme} ${key}`] = {
31+
disabled: true,
32+
};
2633
};
2734
for (const theme of primerThemes) {
2835
githubModes[`primer ${theme.value} ${key}`] = {

.storybook/preview-head.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+
<script defer data-domain="scottnath.com" src="https://plausible.io/js/script.js"></script>

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Web components which display profile information from various websites
99

1010
## Components
1111

12-
## Modules
13-
1412
<dl>
1513
<dt><a href="#module_GitHubUser">GitHubUser</a></dt>
1614
<dd><p>GitHub user profile web component</p>
@@ -41,12 +39,13 @@ GitHub user profile web component
4139
| login | <code>string</code> | User's GitHub login |
4240
| avatar_url | <code>string</code> | URL to user's avatar |
4341
| name | <code>string</code> | User's name |
44-
| [fetch] | <code>boolean</code> | when true, fetches user from [GitHub api](https://docs.github.com/en/rest/users/users#get-a-user) |
42+
| [fetch] | <code>boolean</code> | when true, fetches user from the [GitHub api](https://docs.github.com/en/rest/users/users#get-a-user) |
4543
| [username] | <code>string</code> | alias for `login` |
4644
| [bio] | <code>string</code> | User's biography content |
4745
| [following] | <code>string</code> | number of people user is following |
4846
| [followers] | <code>string</code> | number of followers |
4947
| [repos] | <code>string</code> | JSON stringified array of repositories |
48+
| [theme] | <code>string</code> | color theme for the component |
5049

5150
**Example**
5251
```js
@@ -69,16 +68,17 @@ GitHub repository web component
6968
| Name | Type | Description |
7069
| --- | --- | --- |
7170
| full_name | <code>string</code> | repository org and name, as in `scottnath/profile-components` |
71+
| [fetch] | <code>boolean</code> | when true, fetches repo from the [GitHub api](https://docs.github.com/en/rest/repos/repos#get-a-repository) |
7272
| [name] | <code>string</code> | repo name |
7373
| [org] | <code>string</code> | repo owner organization's login, found at `<REST_RESPONSE>.organization.login` |
7474
| [description] | <code>string</code> | repo description |
7575
| [language] | <code>string</code> | programming language used in repo |
7676
| [stargazers_count] | <code>string</code> | number of stars |
7777
| [forks_count] | <code>string</code> | number of forks |
7878
| [subscribers_count] | <code>string</code> | number of watchers |
79-
| [fetch] | <code>boolean</code> | when true, fetches repo from [GitHub api](https://docs.github.com/en/rest/repos/repos#get-a-repository) |
8079
| [itemprop] | <code>string</code> | Itemprop content to go with a containing component's itemscope |
8180
| [no_org] | <code>string</code> | Do not include the repo owner or organization |
81+
| [theme] | <code>string</code> | color theme for the component |
8282

8383
**Example**
8484
```js
@@ -101,14 +101,15 @@ dev.to user profile web component
101101
| Name | Type | Description |
102102
| --- | --- | --- |
103103
| username | <code>string</code> | User's dev.to username |
104+
| [fetch] | <code>boolean</code> | when true, fetches user and posts from the [Forem API](https://developers.forem.com/api/v0#tag/users/operation/getUser) |
104105
| [name] | <code>string</code> | The name of the user |
105106
| [summary] | <code>string</code> | The user's bio |
106107
| [joined_at] | <code>string</code> | The date the user joined |
107108
| [profile_image] | <code>string</code> | The URL of the user's profile image |
108-
| [fetch] | <code>boolean</code> | when true, fetches user and posts from api |
109109
| [post_count] | <code>number</code> | The number of posts the user has published |
110110
| [latest_post] | <code>string</code> | User's latest post content, JSON stringified |
111111
| [popular_post] | <code>string</code> | User's most popular post content, JSON stringified |
112+
| [theme] | <code>string</code> | color theme for the component |
112113

113114
**Example**
114115
```js
@@ -135,7 +136,7 @@ dev.to post web component
135136
| url | <code>string</code> | Post URL |
136137
| cover_image | <code>string</code> | Post cover image URL |
137138
| social_image | <code>string</code> | Post social image URL |
138-
| [fetch] | <code>boolean</code> | when true, fetches post from api |
139+
| [fetch] | <code>boolean</code> | when true, fetches post from the [Forem API](https://developers.forem.com/api/v0#tag/articles/operation/getArticleById) |
139140

140141
**Example**
141142
```js

chromatic.config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"projectId":"Project:64fb63fd226c27fbcd62f93a","projectToken":"chpt_97a8174bb6bd68e"}

custom-elements.json

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
"name": "full_name",
3636
"kind": "field"
3737
},
38+
{
39+
"type": {
40+
"text": "boolean"
41+
},
42+
"description": "when true, fetches repo from the [GitHub api](https://docs.github.com/en/rest/repos/repos#get-a-repository)",
43+
"name": "fetch",
44+
"kind": "field"
45+
},
3846
{
3947
"type": {
4048
"text": "string"
@@ -93,26 +101,26 @@
93101
},
94102
{
95103
"type": {
96-
"text": "boolean"
104+
"text": "string"
97105
},
98-
"description": "when true, fetches repo from [GitHub api](https://docs.github.com/en/rest/repos/repos#get-a-repository)",
99-
"name": "fetch",
106+
"description": "Itemprop content to go with a containing component's itemscope",
107+
"name": "itemprop",
100108
"kind": "field"
101109
},
102110
{
103111
"type": {
104112
"text": "string"
105113
},
106-
"description": "Itemprop content to go with a containing component's itemscope",
107-
"name": "itemprop",
114+
"description": "Do not include the repo owner or organization",
115+
"name": "no_org",
108116
"kind": "field"
109117
},
110118
{
111119
"type": {
112120
"text": "string"
113121
},
114-
"description": "Do not include the repo owner or organization",
115-
"name": "no_org",
122+
"description": "color theme for the component",
123+
"name": "theme",
116124
"kind": "field"
117125
}
118126
],
@@ -196,7 +204,7 @@
196204
"type": {
197205
"text": "boolean"
198206
},
199-
"description": "when true, fetches user from [GitHub api](https://docs.github.com/en/rest/users/users#get-a-user)",
207+
"description": "when true, fetches user from the [GitHub api](https://docs.github.com/en/rest/users/users#get-a-user)",
200208
"name": "fetch",
201209
"kind": "field"
202210
},
@@ -239,6 +247,14 @@
239247
"description": "JSON stringified array of repositories",
240248
"name": "repos",
241249
"kind": "field"
250+
},
251+
{
252+
"type": {
253+
"text": "string"
254+
},
255+
"description": "color theme for the component",
256+
"name": "theme",
257+
"kind": "field"
242258
}
243259
],
244260
"superclass": {
@@ -293,6 +309,14 @@
293309
"name": "username",
294310
"kind": "field"
295311
},
312+
{
313+
"type": {
314+
"text": "boolean"
315+
},
316+
"description": "when true, fetches user and posts from the [Forem API](https://developers.forem.com/api/v0#tag/users/operation/getUser)",
317+
"name": "fetch",
318+
"kind": "field"
319+
},
296320
{
297321
"type": {
298322
"text": "string"
@@ -325,14 +349,6 @@
325349
"name": "profile_image",
326350
"kind": "field"
327351
},
328-
{
329-
"type": {
330-
"text": "boolean"
331-
},
332-
"description": "when true, fetches user and posts from api",
333-
"name": "fetch",
334-
"kind": "field"
335-
},
336352
{
337353
"type": {
338354
"text": "number"
@@ -356,6 +372,14 @@
356372
"description": "User's most popular post content, JSON stringified",
357373
"name": "popular_post",
358374
"kind": "field"
375+
},
376+
{
377+
"type": {
378+
"text": "string"
379+
},
380+
"description": "color theme for the component",
381+
"name": "theme",
382+
"kind": "field"
359383
}
360384
],
361385
"superclass": {
@@ -446,7 +470,7 @@
446470
"type": {
447471
"text": "boolean"
448472
},
449-
"description": "when true, fetches post from api",
473+
"description": "when true, fetches post from the [Forem API](https://developers.forem.com/api/v0#tag/articles/operation/getArticleById)",
450474
"name": "fetch",
451475
"kind": "field"
452476
}

lib/cli.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import { Command } from 'commander';
44

5-
import { writeDevCssFile } from '../src/devto/utils/forem.js';
6-
import { writePrimerCssFile } from '../src/github/utils/primer.js';
7-
import { generateFixtures as genFixGitHub } from '../src/github/utils/fixtures.js';
5+
import { writeDevCssFile } from '../src/devto/helpers/forem.js';
6+
import { writePrimerCssFile } from '../src/github/helpers/primer.js';
7+
import { generateFixtures as genFixGitHub } from '../src/github/helpers/fixtures.js';
88
import { generateFixtures as genFixDevTo } from '../src/devto/fixtures/utils.js';
99
import { generateDocs } from './jsdoc.js';
1010

lib/custom-elements-manifest.config.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,4 @@ export default {
1616
dependencies: false,
1717
dev: false,
1818
packagejson: true,
19-
plugins: [
20-
readmePlugin({
21-
from: getModulePaths().root,
22-
to: 'custom-elements-readme.md',
23-
omitSections: ['exports']
24-
}),
25-
],
2619
}

lib/jsdoc.js

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ export const generateDocs = async () => {
3939
pathFromRoot('src/devto/user/index.js'),
4040
pathFromRoot('src/devto/post/index.js'),
4141
],
42+
// @todo automate changing `Modules` to `Components`
4243
},
4344
{
44-
title: `GitHub profile components' utilities`,
45-
dir: pathFromRoot('src/github/utils'),
46-
files: pathFromRoot('src/github/utils/*.js'),
45+
title: `GitHub profile components' helpers`,
46+
dir: pathFromRoot('src/github/helpers'),
47+
files: pathFromRoot('src/github/helpers/*.js'),
4748
},
4849
{
4950
title: 'GitHub utilities',
@@ -56,39 +57,11 @@ export const generateDocs = async () => {
5657
pathFromRoot('src/github/repository/content.js'),
5758
pathFromRoot('src/github/index.js'),
5859
],
59-
filename: 'UTILITIES.md',
6060
},
6161
{
62-
title: 'GitHub repository details component',
63-
dir: pathFromRoot('src/github/repository'),
64-
files: [
65-
pathFromRoot('src/github/repository/index.js'),
66-
pathFromRoot('src/github/repository/content.js'),
67-
pathFromRoot('src/github/repository/html.js'),
68-
],
69-
},
70-
{
71-
title: `DEV profile components' utilities`,
72-
dir: pathFromRoot('src/devto/utils'),
73-
files: pathFromRoot('src/devto/utils/*.js'),
74-
},
75-
{
76-
title: 'Dev user profile component',
77-
dir: pathFromRoot('src/devto/user'),
78-
files: [
79-
pathFromRoot('src/devto/user/index.js'),
80-
pathFromRoot('src/devto/user/content.js'),
81-
pathFromRoot('src/devto/user/html.js'),
82-
],
83-
},
84-
{
85-
title: 'DEV post component',
86-
dir: pathFromRoot('src/devto/post'),
87-
files: [
88-
pathFromRoot('src/devto/post/index.js'),
89-
pathFromRoot('src/devto/post/content.js'),
90-
pathFromRoot('src/devto/post/html.js'),
91-
],
62+
title: `DEV profile components' helpers`,
63+
dir: pathFromRoot('src/devto/helpers'),
64+
files: pathFromRoot('src/devto/helpers/*.js'),
9265
},
9366
{
9467
title: 'DEV utilities',
@@ -101,7 +74,6 @@ export const generateDocs = async () => {
10174
pathFromRoot('src/devto/post/content.js'),
10275
pathFromRoot('src/devto/index.js'),
10376
],
104-
filename: 'UTILITIES.md',
10577
},
10678
]
10779
for (const toDoc of toDocs) {

0 commit comments

Comments
 (0)