Repository navigation
docs: rewrite the README for any package manager (BITS-221) #27
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
3589c68
docs: rewrite the README for any package manager (BITS-221)
PhilReinking be13e04
docs: set darkMode to class in the README's Tailwind config (BITS-221)
PhilReinking 09b99a8
Merge remote-tracking branch 'origin/main' into docs/bits-221-readme
PhilReinking File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,120 @@ | ||
| # ui | ||
| # @deck9/ui | ||
|
|
||
| ## Project setup | ||
| Vue 3 components for Deck9 apps such as [Input](https://github.com/deck9/input), styled with Tailwind CSS 3. Storybook is the component reference: run `npm run storybook` in this repo. | ||
|
|
||
| ## Install | ||
|
|
||
| ```sh | ||
| npm install @deck9/ui | ||
| pnpm add @deck9/ui | ||
| yarn add @deck9/ui | ||
| bun add @deck9/ui | ||
| ``` | ||
| yarn install | ||
|
|
||
| Vue 3.3 or newer is a peer dependency. Pre-releases are on the `next` tag: `npm install @deck9/ui@next`. | ||
|
|
||
| The steps below use npm. With another package manager, swap `npm install` for `pnpm add`, `yarn add` or `bun add`. | ||
|
|
||
| ## Use it in an app | ||
|
|
||
| ### Tailwind | ||
|
|
||
| The package ships no CSS: its components use Tailwind 3 classes, and the app's Tailwind build creates them. In a new app, set up Tailwind 3: | ||
|
|
||
| ```sh | ||
| npm install -D tailwindcss@3 postcss autoprefixer @tailwindcss/forms | ||
| npx tailwindcss init -p | ||
| ``` | ||
|
|
||
| ### Compiles and hot-reloads for development | ||
| In `tailwind.config.js`, add the package's bundle to `content`, plus the `grey` color and the forms plugin the components use. `darkMode: "class"` keeps the components light until the app sets a `dark` class. Without it, they turn dark whenever the computer is in dark mode. | ||
|
|
||
| ```js | ||
| import colors from "tailwindcss/colors"; | ||
| import forms from "@tailwindcss/forms"; | ||
|
|
||
| export default { | ||
| darkMode: "class", | ||
| content: [ | ||
| "./index.html", | ||
| "./src/**/*.{vue,js,ts}", | ||
| "./node_modules/@deck9/ui/dist/src/ui.mjs", | ||
| ], | ||
| theme: { | ||
| extend: { | ||
| colors: { grey: colors.slate }, | ||
| }, | ||
| }, | ||
| plugins: [forms], | ||
| }; | ||
| ``` | ||
| yarn serve | ||
|
|
||
| Put Tailwind's layers in the app's main CSS file (in a Vite app: `src/style.css`): | ||
|
|
||
| ```css | ||
| @tailwind base; | ||
| @tailwind components; | ||
| @tailwind utilities; | ||
| ``` | ||
|
|
||
| ### Compiles and minifies for production | ||
| ### Icons | ||
|
|
||
| The components draw icons with Font Awesome 6 and register only the few they use themselves. The app registers every other icon. Install Font Awesome 6, so the app and the components share one copy: | ||
|
|
||
| ```sh | ||
| npm install @fortawesome/fontawesome-svg-core@6 @fortawesome/free-solid-svg-icons@6 | ||
| ``` | ||
| yarn build | ||
|
|
||
| Register the icons once before the app mounts, for example in `src/main.js`: | ||
|
|
||
| ```js | ||
| import { library } from "@fortawesome/fontawesome-svg-core"; | ||
| import { faRocket } from "@fortawesome/free-solid-svg-icons"; | ||
|
|
||
| library.add(faRocket); | ||
| ``` | ||
|
|
||
| Brand icons work the same way with `@fortawesome/free-brands-svg-icons@6`. | ||
|
|
||
| ### A first component | ||
|
|
||
| ```vue | ||
| <script setup> | ||
| import { D9Button, D9Icon } from "@deck9/ui"; | ||
| </script> | ||
|
|
||
| <template> | ||
| <D9Button label="Launch" icon="rocket" /> | ||
| <D9Icon name="rocket" size="2x" /> | ||
| </template> | ||
| ``` | ||
|
|
||
| ### Lints and fixes files | ||
| Icon names are Font Awesome's names in kebab-case, without `fa`: `faChevronDown` is `chevron-down`. | ||
|
|
||
| ## Develop | ||
|
|
||
| The repo uses npm (`package-lock.json`) and the Node version in `.nvmrc`. | ||
|
|
||
| ```sh | ||
| npm ci | ||
| npm run storybook # Storybook on http://localhost:6006 | ||
| npm test # Vitest | ||
| npm run lint # ESLint | ||
| npm run check # type check | ||
| npm run build # builds dist/, the files npm publishes | ||
| ``` | ||
| yarn lint | ||
|
|
||
| ## Release | ||
|
|
||
| Run `release.sh` on main. It takes the same arguments as `npm version`: | ||
|
|
||
| ```sh | ||
| ./release.sh preminor --preid next # 0.17.0 → 0.18.0-next.0 | ||
| ./release.sh prerelease # 0.18.0-next.0 → 0.18.0-next.1 | ||
| ./release.sh minor # 0.18.0-next.1 → 0.18.0 | ||
| ./release.sh patch # 0.18.0 → 0.18.1 | ||
| ./release.sh major # 0.18.1 → 1.0.0 | ||
| ``` | ||
|
|
||
| ### Customize configuration | ||
| See [Configuration Reference](https://cli.vuejs.org/config/). | ||
| It pulls main, builds, bumps the version, pushes the commit and tag, and creates a GitHub release. You need push rights on main and a logged-in `gh`. The GitHub release starts the publish workflow, which publishes to npm through trusted publishing, without an npm token. | ||
|
|
||
| A version with a dash, like `0.18.0-next.1`, is a pre-release: it goes to the `next` tag. Every other version goes to `latest`, which is what `npm install @deck9/ui` installs. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The components carry
dark:classes, and Tailwind 3 defaults todarkMode: "media". So on a computer in dark mode, D9Input turns dark slate on the app's white page. The repo and Input use"class"; with it the components stay light until the app setsdark:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in be13e04, with one line on why. Checked: in OS dark mode, D9Input now stays white instead of slate-800.