Compare commits

..

16 Commits

Author SHA1 Message Date
Matthew Wang
8ebca95cdd Merge branch 'main' into add-chromatic 2023-08-30 10:28:05 -07:00
Matt Wang
4556629454 Update .gitignore (#1327)
This PR moves over the changes from https://github.com/just-the-docs/just-the-docs/pull/1112, namely making the `.gitignore` more descriptive and bringing it to parity with the recommendations from Jekyll.

---------

Co-authored-by: Peter Mosses <18308236+pdmosses@users.noreply.github.com>
2023-08-30 10:22:08 -07:00
Matthew Wang
bebaee046a Update CHANGELOG.md 2023-08-30 10:14:43 -07:00
Michael Flanakin
c115932255 Fix Windows emoji font fallback (#1337) 2023-08-30 10:13:18 -07:00
dependabot[bot]
5deba46197 Bump prettier from 3.0.2 to 3.0.3 (#1338)
Bumps [prettier](https://github.com/prettier/prettier) from 3.0.2 to 3.0.3.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-30 09:43:03 -07:00
Matthew Wang
720dd430d7 Update outdated ruby workflow 2023-08-26 13:41:08 -04:00
Matthew Wang
3a205e545c Fix typo in Changelog 2023-08-26 13:36:37 -04:00
Matthew Wang
8f9c0c44e1 Fix lockfile after version bump 2023-08-26 13:35:24 -04:00
Matthew Wang
cef1203301 v0.6.1 2023-08-26 13:33:17 -04:00
Peter Mosses
6041c7cd8e Fix JS error for pages excluded from navigation (#1332)
Fix #1331

Pages excluded from the navigation do not have a second (page-specific) stylesheet in the head. When JS is enabled, an error arises when such a page is loaded, due to `initNav()` trying to disable a non-existent stylesheet.

This PR stops JS trying to disable the second stylesheet when it doesn't exist.

Note that issue #1331 was reported in connection with optimising the build of the endoflife.date site by following [my suggestion](https://github.com/just-the-docs/just-the-docs/pull/1244#issuecomment-1660246728) in #1244, but the bug also appears on the theme website at https://just-the-docs.com/404.html.
2023-08-26 13:30:53 -04:00
Matthew Wang
3c816ce3de Temporary change to trigger storybook diff 2023-04-24 15:05:44 -07:00
Matthew Wang
4ddb5ef460 Use chromatic action instead 2023-04-24 14:52:03 -07:00
Matthew Wang
bd2d1dc046 Bump action 2023-04-24 14:48:31 -07:00
Matthew Wang
90b9c0cce0 Add action 2023-04-24 14:44:58 -07:00
Matthew Wang
f55f648479 Install chromatic 2023-04-24 13:40:46 -07:00
Matthew Wang
7e6bbb9e6a First draft: add chromatic/storybook 2023-04-24 13:20:58 -07:00
29 changed files with 23350 additions and 827 deletions

15
.babelrc.json Normal file
View File

@@ -0,0 +1,15 @@
{
"sourceType": "unambiguous",
"presets": [
[
"@babel/preset-env",
{
"targets": {
"chrome": 100
}
}
],
"@babel/preset-typescript"
],
"plugins": []
}

51
.github/workflows/chromatic.yml vendored Normal file
View File

@@ -0,0 +1,51 @@
on:
push:
branches:
- main
pull_request:
branches:
- main
name: 'Chromatic'
jobs:
chromatic:
name: "Chromatic"
strategy:
matrix:
jekyll-version: [4.3]
os: [ ubuntu-latest ]
ruby-version: [3.1]
node-version: [18.x]
runs-on: ${{ matrix.os }}
steps:
# Ruby setup
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: false
- name: Bundle Install
run: bundle install
- name: Install Jekyll ${{ matrix.jekyll-version }}
run: gem install jekyll -v ${{ matrix.jekyll-version }}
- name: Init Search
run: bundle exec rake search:init
- name: Build Site
run: bundle exec jekyll build
# Node setup
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run build-storybook
- name: Publish to Chromatic
uses: chromaui/action@v1
env:
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

View File

@@ -10,8 +10,8 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Ruby 3.2 - name: Setup Ruby 3.2
uses: actions/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: "3.2" ruby-version: "3.2"

35
.gitignore vendored
View File

@@ -1,8 +1,33 @@
# Not sure what a .gitignore is?
# See: https://git-scm.com/docs/gitignore
# The first files are directly copied from Jekyll's first-party docs on `.gitignore` files:
# https://jekyllrb.com/tutorials/using-jekyll-with-bundler/#commit-to-source-control
# Ignore the default location of the built site, and caches and metadata generated by Jekyll
_site/
.sass-cache/
.jekyll-cache/
.jekyll-metadata
# Ignore folders generated by Bundler
.bundle/
vendor/
# These next files are used by Just the Docs developers. They are not necessary for end users of the theme, only developers.
# We use Stylelint and Prettier, JavaScript tools, to lint and format our own code,
# We use Node.js as our runtime, so we ignore node_modules
node_modules
# We also use Storybook to test regressions in changes; we ignore the build output.
storybook-static
# .DS_Store is a macOS-only metadata file about directories. Convention is to not commit them.
# See: https://en.wikipedia.org/wiki/.DS_Store
.DS_Store
# These are legacy globs that typically target Ruby theme developers. We may change these at a later date.
*.gem *.gem
.bundle .bundle
.ruby-version .ruby-version
.jekyll-cache
.sass-cache
_site
node_modules
.DS_Store

17
.storybook/main.js Normal file
View File

@@ -0,0 +1,17 @@
/** @type { import('@storybook/html-webpack5').StorybookConfig } */
const config = {
stories: ["../stories/**/*.mdx", "../stories/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/html-webpack5",
options: {},
},
docs: {
autodocs: "tag",
},
}
export default config

14
.storybook/preview.js Normal file
View File

@@ -0,0 +1,14 @@
/** @type { import('@storybook/html').Preview } */
const preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
}
export default preview

View File

@@ -17,7 +17,25 @@ This website is built from the `HEAD` of the `main` branch of the theme reposito
Code changes to `main` that are *not* in the latest release: Code changes to `main` that are *not* in the latest release:
- N/A - Fixed: Windows emoji font fallback by [@flanakin] in [#1337]
[#1337]: https://github.com/just-the-docs/just-the-docs/pull/1337
### New Contributors
- [@flanakin] made their first contribution in [#1337]
[@flanakin]: https://github.com/flanakin
## Release v0.6.1
Hi all, this is a small patch release that only includes one change: resolving a bug introduced in 0.6.0 that causes a JS error for pages excluded from navigation.
### Bugfixes
- Fixed: JS error for pages excluded from navigation by [@pdmosses] in [#1332]
[#1332]: https://github.com/just-the-docs/just-the-docs/pull/1332
## Release v0.6.0 ## Release v0.6.0

View File

@@ -1,7 +1,7 @@
PATH PATH
remote: . remote: .
specs: specs:
just-the-docs (0.6.0) just-the-docs (0.6.1)
jekyll (>= 3.8.5) jekyll (>= 3.8.5)
jekyll-include-cache jekyll-include-cache
jekyll-seo-tag (>= 2.0) jekyll-seo-tag (>= 2.0)

View File

@@ -48,6 +48,7 @@ exclude:
- Dockerfile - Dockerfile
# theme test code # theme test code
- fixtures/ - fixtures/
- stories/
# Set a path/url to a logo that will be displayed instead of the title # Set a path/url to a logo that will be displayed instead of the title
#logo: "/assets/images/just-the-docs.png" #logo: "/assets/images/just-the-docs.png"
@@ -140,11 +141,7 @@ gh_edit_branch: "main" # the branch that your docs is served from
gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately
# Color scheme currently only supports "dark", "light"/nil (default), or a custom scheme that you define # Color scheme currently only supports "dark", "light"/nil (default), or a custom scheme that you define
color_scheme: auto color_scheme: nil
color_scheme_options:
enable_localstorage: true
enable_switch: true
switch_options: ["auto", "light", "dark"]
callouts_level: quiet # or loud callouts_level: quiet # or loud
callouts: callouts:

View File

@@ -11,12 +11,5 @@
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
{% if site.color_scheme_options and site.color_scheme_options.switch_options %}
<li class="aux-nav-list-item">
<button class="site-button color-scheme-switch-theme-button" aria-label="Switch color scheme">
<svg aria-hidden="true" class="site-button-icon"><use href="#svg-{{ site.color_scheme | default: 'light' }}"></use></svg>
</button>
</li>
{% endif %}
</ul> </ul>
</nav> </nav>

View File

@@ -5,7 +5,7 @@
<div></div> <div></div>
{% endif %} {% endif %}
{% include header_custom.html %} {% include header_custom.html %}
{% if site.aux_links or site.color_scheme_options and site.color_scheme_options.switch_options %} {% if site.aux_links %}
{% include components/aux_nav.html %} {% include components/aux_nav.html %}
{% endif %} {% endif %}
</div> </div>

View File

@@ -14,48 +14,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge"> <meta http-equiv="X-UA-Compatible" content="IE=Edge">
{% if site.color_scheme_options and site.color_scheme_options.enable_localstorage %} <link rel="stylesheet" href="{{ '/assets/css/just-the-docs-default.css' | relative_url }}">
<script>
(function(){
function createThemeStylesheet(theme, media) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = "{{ '/assets/css/just-the-docs-*.css' | relative_url }}".replace("*",theme);
if(media) link.media = media;
return link;
}
var theme = window.localStorage.getItem('theme');
var head = document.getElementsByTagName('head')[0];
if (theme === null) {
theme = "{{ site.color_scheme }}";
}
if (theme === "nil") {
theme = "default";
}
if (theme === "auto") {
head.appendChild(createThemeStylesheet('light', '(prefers-color-scheme: light)'));
head.appendChild(createThemeStylesheet('dark', '(prefers-color-scheme: dark)'));
} else {
head.appendChild(createThemeStylesheet(theme || "default"));
}
})();
</script>
{% else %}
{% case site.color_scheme %}
{% when "auto" %}
<link rel="stylesheet" href="{{ '/assets/css/just-the-docs-light.css' | relative_url }}" type="text/css" media="(prefers-color-scheme: light)">
<link rel="stylesheet" href="{{ '/assets/css/just-the-docs-dark.css' | relative_url }}" type="text/css" media="(prefers-color-scheme: dark)">
{% when nil %}
<link rel="stylesheet" href="{{ '/assets/css/just-the-docs-default.css' | relative_url }}" type="text/css">
{% else %}
<link rel="stylesheet" href="{{ site.color_scheme | prepend: '/assets/css/just-the-docs-' | append: '.css' | relative_url }}" type="text/css">
{% endcase %}
{% endif %}
{% include head_nav.html %} {% include head_nav.html %}

View File

@@ -28,7 +28,7 @@
{%- assign color_scheme = "light" -%} {%- assign color_scheme = "light" -%}
{%- endif %} {%- endif %}
@import "./color_schemes/light"; @import "./color_schemes/light";
{% unless color_scheme == "light" or color_scheme == "auto" %} {% unless color_scheme == "light" %}
@import "./color_schemes/{{ color_scheme }}"; @import "./color_schemes/{{ color_scheme }}";
{% endunless %} {% endunless %}
{{ activation }} {{ activation }}

View File

@@ -10,7 +10,4 @@
{% if site.enable_copy_code_button != false %} {% if site.enable_copy_code_button != false %}
{% include icons/code_copy.html %} {% include icons/code_copy.html %}
{% endif %} {% endif %}
{% if site.color_scheme_options and site.color_scheme_options.enable_switch %}
{% include icons/switch_color_scheme.html %}
{% endif %}
</svg> </svg>

Before

Width:  |  Height:  |  Size: 576 B

After

Width:  |  Height:  |  Size: 432 B

View File

@@ -1,29 +0,0 @@
<!-- Feather. Public domain or under the CC0-1.0-Universal license: https://github.com/python/peps/blob/ebff37d5e7728377035b1e1ce9c9796ed63940b1/pep_sphinx_extensions/LICENCE.rst -->
<symbol id="svg-auto" viewBox="0 0 24 24" pointer-events="all">
<title>Following system colour scheme</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="9"></circle>
<path d="M12 3v18m0-12l4.65-4.65M12 14.3l7.37-7.37M12 19.6l8.85-8.85"></path>
</svg>
</symbol>
<symbol id="svg-dark" viewBox="0 0 24 24" pointer-events="all">
<title>Selected dark colour scheme</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z"></path>
</svg>
</symbol>
<symbol id="svg-light" viewBox="0 0 24 24" pointer-events="all">
<title>Selected light colour scheme</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
</symbol>

View File

@@ -105,7 +105,7 @@
} }
.btn-purple { .btn-purple {
@include btn-color($white, $purple-100); @include btn-color($white, $purple-300);
} }
.btn-blue { .btn-blue {

View File

@@ -140,32 +140,11 @@
} }
} }
button.site-button {
background: none;
border: none;
}
.site-button { .site-button {
display: flex; display: flex;
height: 100%; height: 100%;
padding: $gutter-spacing-sm; padding: $gutter-spacing-sm;
align-items: center; align-items: center;
.site-button-icon {
width: #{$sp-4 * 1.2};
height: #{$sp-4 * 1.2};
align-self: center;
color: $grey-dk-000;
cursor: pointer;
}
&:hover,
&:focus,
&:active {
.site-button-icon {
color: $link-color;
}
}
} }
@include mq(md) { @include mq(md) {

View File

@@ -2,7 +2,7 @@
// prettier-ignore // prettier-ignore
$body-font-family: system-ui, -apple-system, blinkmacsystemfont, "Segoe UI", $body-font-family: system-ui, -apple-system, blinkmacsystemfont, "Segoe UI",
roboto, "Helvetica Neue", arial, sans-serif !default; roboto, "Helvetica Neue", arial, sans-serif, "Segoe UI Emoji" !default;
$mono-font-family: "SFMono-Regular", menlo, consolas, monospace !default; $mono-font-family: "SFMono-Regular", menlo, consolas, monospace !default;
$root-font-size: 16px !default; // DEPRECATED: previously base font-size for rems $root-font-size: 16px !default; // DEPRECATED: previously base font-size for rems
$body-line-height: 1.4 !default; $body-line-height: 1.4 !default;

View File

@@ -1,6 +1,6 @@
--- ---
--- ---
{% if site.color_scheme and site.color_scheme != "nil" and site.color_scheme != "auto" %} {% if site.color_scheme and site.color_scheme != "nil" %}
{% assign color_scheme = site.color_scheme %} {% assign color_scheme = site.color_scheme %}
{% else %} {% else %}
{% assign color_scheme = "light" %} {% assign color_scheme = "light" %}

View File

@@ -76,7 +76,9 @@ function initNav() {
// The page-specific stylesheet is assumed to have index 1 in the list of stylesheets. // The page-specific stylesheet is assumed to have index 1 in the list of stylesheets.
function disableHeadStyleSheet() { function disableHeadStyleSheet() {
if (document.styleSheets[1]) {
document.styleSheets[1].disabled = true; document.styleSheets[1].disabled = true;
}
} }
{%- if site.search_enabled != false %} {%- if site.search_enabled != false %}
@@ -465,56 +467,13 @@ function searchLoaded(index, docs) {
// Switch theme // Switch theme
jtd.getTheme = function() { jtd.getTheme = function() {
var cssFile = document.querySelector('[rel="stylesheet"]'); var cssFileHref = document.querySelector('[rel="stylesheet"]').getAttribute('href');
if(cssFile.hasAttribute('media')) return 'auto';
var cssFileHref = cssFile.getAttribute('href');
return cssFileHref.substring(cssFileHref.lastIndexOf('-') + 1, cssFileHref.length - 4); return cssFileHref.substring(cssFileHref.lastIndexOf('-') + 1, cssFileHref.length - 4);
} }
jtd.setTheme = function(theme) { jtd.setTheme = function(theme) {
function createThemeStylesheet(theme, media) { var cssFile = document.querySelector('[rel="stylesheet"]');
var link = document.createElement('link'); cssFile.setAttribute('href', '{{ "assets/css/just-the-docs-" | relative_url }}' + theme + '.css');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = "{{ '/assets/css/just-the-docs-*.css' | relative_url }}".replace("*",theme);
if(media) link.media = media;
return link;
}
var cssFiles = [...document.querySelectorAll('[rel="stylesheet"]')];
if(theme === "auto") {
cssFiles.at(-1).insertAdjacentElement('afterend', createThemeStylesheet('light', '(prefers-color-scheme: light)'));
cssFiles.at(-1).insertAdjacentElement('afterend', createThemeStylesheet('dark', '(prefers-color-scheme: dark)'));
} else {
cssFiles.at(-1).insertAdjacentElement('afterend', createThemeStylesheet(theme || "default"));
}
setTimeout(() => cssFiles.forEach(it => it.remove()), 100);
}
jtd.switchThemeButton = function(button, event) {
{% if site.color_scheme_options and site.color_scheme_options.switch_options %}
const themes = {{ site.color_scheme_options.switch_options | jsonify }};
{% else %}
const themes = ["auto", "light", "dark"];
{% endif %}
var currentTheme = jtd.getTheme();
var nextTheme = themes[(themes.indexOf(currentTheme)+1)%themes.length];
jtd.setTheme(nextTheme);
button.getElementsByTagName('svg')[0].getElementsByTagName('use')[0].setAttribute('href',`#svg-${nextTheme}`);
{% if site.color_scheme_options and site.color_scheme_options.enable_localstorage %}
window.localStorage.setItem('theme', nextTheme);
{% endif %}
}
function initSwitchThemeButton() {
var buttons = [...document.getElementsByClassName("color-scheme-switch-theme-button")];
{% if site.color_scheme_options and site.color_scheme_options.enable_localstorage != false %}
theme = window.localStorage.getItem('theme');
if(theme != null){
buttons.forEach(button => button.getElementsByTagName('svg')[0].getElementsByTagName('use')[0].setAttribute('href',`#svg-${theme}`));
}
{% endif %}
buttons.forEach(button => jtd.addEvent(button, 'click', event => jtd.switchThemeButton(button, event)));
} }
// Note: pathname can have a trailing slash on a local jekyll server // Note: pathname can have a trailing slash on a local jekyll server
@@ -576,9 +535,6 @@ jtd.onReady(function(){
{%- if site.search_enabled != false %} {%- if site.search_enabled != false %}
initSearch(); initSearch();
{%- endif %} {%- endif %}
{%- if site.enable_switch_color_scheme != false %}
initSwitchThemeButton();
{%- endif %}
activateNav(); activateNav();
scrollNav(); scrollNav();
}); });

View File

@@ -21,7 +21,7 @@ nav_order: 1
By default, Just the Docs uses a native system font stack for sans-serif fonts: By default, Just the Docs uses a native system font stack for sans-serif fonts:
```scss ```scss
system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Segoe UI Emoji"
``` ```
ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ

View File

@@ -2,7 +2,7 @@
Gem::Specification.new do |spec| Gem::Specification.new do |spec|
spec.name = "just-the-docs" spec.name = "just-the-docs"
spec.version = "0.6.0" spec.version = "0.6.1"
spec.authors = ["Patrick Marsceill", "Matthew Wang"] spec.authors = ["Patrick Marsceill", "Matthew Wang"]
spec.email = ["patrick.marsceill@gmail.com", "matt@matthewwang.me"] spec.email = ["patrick.marsceill@gmail.com", "matt@matthewwang.me"]

23616
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,31 @@
{ {
"name": "just-the-docs", "name": "just-the-docs",
"version": "0.3.3", "version": "0.5.0",
"description": "A modern Jekyll theme for documentation", "description": "A modern Jekyll theme for documentation",
"repository": "just-the-docs/just-the-docs", "repository": {
"type": "git",
"url": "git+https://github.com/just-the-docs/just-the-docs.git"
},
"license": "MIT", "license": "MIT",
"bugs": "https://github.com/just-the-docs/just-the-docs/issues", "bugs": {
"url": "https://github.com/just-the-docs/just-the-docs/issues"
},
"devDependencies": { "devDependencies": {
"@babel/preset-env": "^7.21.4",
"@babel/preset-typescript": "^7.21.4",
"@storybook/addon-essentials": "^7.0.7",
"@storybook/addon-interactions": "^7.0.7",
"@storybook/addon-links": "^7.0.7",
"@storybook/blocks": "^7.0.7",
"@storybook/html": "^7.0.7",
"@storybook/html-webpack5": "^7.0.7",
"@storybook/testing-library": "^0.0.14-next.2",
"chromatic": "^6.17.3",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "^3.0.2", "prettier": "^3.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"storybook": "^7.0.7",
"stylelint": "^15.10.3", "stylelint": "^15.10.3",
"stylelint-config-standard-scss": "^10.0.0" "stylelint-config-standard-scss": "^10.0.0"
}, },
@@ -16,7 +34,10 @@
"lint:css": "stylelint '**/*.scss'", "lint:css": "stylelint '**/*.scss'",
"lint:formatting": "prettier --check '**/*.{scss,js,json}'", "lint:formatting": "prettier --check '**/*.{scss,js,json}'",
"format": "prettier --write '**/*.{scss,js,json}'", "format": "prettier --write '**/*.{scss,js,json}'",
"test": "npm run lint" "test": "npm run lint",
"storybook": "bundle exec jekyll build && storybook dev -p 6006",
"build-storybook": "bundle exec jekyll build && storybook build",
"chromatic": "npx chromatic --project-token=9355f489c51b -d storybook-static"
}, },
"stylelint": { "stylelint": {
"ignoreFiles": [ "ignoreFiles": [
@@ -43,5 +64,7 @@
"singleQuote": false, "singleQuote": false,
"tabWidth": 2, "tabWidth": 2,
"trailingComma": "es5" "trailingComma": "es5"
} },
"homepage": "https://just-the-docs.com",
"_id": "just-the-docs@0.5.0"
} }

7
stories/Introduction.mdx Normal file
View File

@@ -0,0 +1,7 @@
import { Meta } from '@storybook/blocks';
<Meta title="Example/Introduction" />
# Storybook for Just the Docs
A WIP [Storybook](https://storybook.js.org/) for Just the Docs.

View File

@@ -0,0 +1,11 @@
import "../../_site/assets/css/just-the-docs-default.css"
export const createButton = ({ variant = "default", label, size = "4" }) => {
const btn = document.createElement("button")
btn.type = "button"
btn.innerText = label
btn.className = ["btn", `btn-${variant}`, `fs-${size}`].join(" ")
return btn
}

View File

@@ -0,0 +1,68 @@
import { createButton } from "./Button"
export default {
title: "UI Components/Button",
tags: ["autodocs"],
render: ({ label, ...args }) => {
return createButton({ label, ...args })
},
argTypes: {
label: { control: "text" },
size: {
control: { type: "select" },
options: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
},
variant: {
control: { type: "select" },
options: ["default", "primary", "purple", "blue", "green", "outline"],
},
},
}
export const Default = {
args: {
variant: "default",
label: "Button",
size: 4,
},
}
export const Primary = {
args: {
variant: "primary",
label: "Button",
size: 4,
},
}
export const Purple = {
args: {
variant: "purple",
label: "Button",
size: 4,
},
}
export const Blue = {
args: {
variant: "blue",
label: "Button",
size: 4,
},
}
export const Green = {
args: {
variant: "green",
label: "Button",
size: 4,
},
}
export const Outline = {
args: {
variant: "outline",
label: "Button",
size: 4,
},
}

View File

@@ -0,0 +1,10 @@
import "../../_site/assets/css/just-the-docs-default.css"
export const createLabel = ({ variant = "default", label, size = "4" }) => {
const btn = document.createElement("span")
btn.innerText = label
btn.className = ["label", `label-${variant}`, `fs-${size}`].join(" ")
return btn
}

View File

@@ -0,0 +1,68 @@
import { createLabel } from "./Label"
export default {
title: "UI Components/Label",
tags: ["autodocs"],
render: ({ label, ...args }) => {
return createLabel({ label, ...args })
},
argTypes: {
label: { control: "text" },
size: {
control: { type: "select" },
options: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
},
variant: {
control: { type: "select" },
options: ["default", "purple", "blue", "green", "red", "yellow"],
},
},
}
export const Default = {
args: {
variant: "default",
label: "Label",
size: 4,
},
}
export const Purple = {
args: {
variant: "purple",
label: "Label",
size: 4,
},
}
export const Blue = {
args: {
variant: "blue",
label: "Label",
size: 4,
},
}
export const Green = {
args: {
variant: "green",
label: "Label",
size: 4,
},
}
export const Red = {
args: {
variant: "red",
label: "Label",
size: 4,
},
}
export const Yellow = {
args: {
variant: "yellow",
label: "Label",
size: 4,
},
}