Better Stylekit example website
npm install better-stylekit
Stylekit components (CSS and JS) should work in following browsers:
- Chrome 58 or newer
- Safari 11 (Desktop), 11 and 10 for iOS (revisit in two months)
- Firefox 57 and newer
- Edge 16 and newer
- Use SUIT CSS naming conventions for CSS classes and component variables
- Use Bourbon mixins
- Assume ES6 environment
- Assume DOM4 environment
- Polyfill when in doubt
- Prefer leaving library integrations to the user rather than vendoring/bundling them
- Make sure each component has at least one customizable
data-qa
attribute- Put the qa attribute on the form element (
<select>
,<input>
, etc.) directly, if the component is simple - For complex components with multiple inputs, put the qa attribute on the parent and add non-customizable qa attributes for the child inputs. For example, if there is a two-choice toggle component, add a customizable qa attribute to the main parent element, and qa attributes like "choice-1", "choice-2" to the proper inputs.
- Put the qa attribute on the form element (
- Always include a
type
for<button>
tags - Always include a
role
attribute where it makes sense - Sass mixins shared across different components should be in a shared file
- Set
sensitive
to add thebsk-Field--sensitive
class so the field is obscured in FullStory:{{bsk-field sensitive=true ...}}
-
npm install
the stylekit. - Add
stylekit/dist/*.css
,stylekit/dist/*.js
, andstylekit/fonts/*
to your build pipeline. - Add
stylekit-web.css
orstylekit-web.min.css
to your page as a stylesheet. - Add
stylekit-web.js
orstylekit-web.min.js
to your page as a script. - Make sure the stylekit fonts are accessible under
fonts/
in your CSS directory.
You can use the stylekit JS via the global BetterStylekit
object.
npm install ember-better-stylekit
See the ember-better-stylekit README for more details.
Component | HTML + CSS | JS | Ember | React |
---|---|---|---|---|
Button | ✔ | ✌ | ✔ | |
Card | ✔ | ✌ | ✔ | |
CardList | ✔ | ✔ | ||
Dropdown | ✔ | ✌ | ✔ | |
RadioList | ✔ | ✌ | ✔ | |
Checkbox | ✔ | ✌ | ✔ | |
Field | ✔ | ✔ | ||
FieldSet | ✔ | ✔ | ✔ | |
Range | ✔ | ✔ | ||
Toggle | ✔ | ✌ | ✔ | |
Tabs | ✔ | |||
Modal |
✌ = not necessary
-
BSK
refers to your local/stylekit
-
ESK
refers to your local/stylekit/ember-better-stylekit
-
Better Stylekit
refers to the published NPM package
IMPORTANT: CSS changes made in BSK
do not automatically update the styles of ESK
. ESK
uses Better Stylekit
for it's styling. In order to have BSK
css changes propagate without having to publish to NPM check the Building CSS Changes section below.
- In order to access
BSK
andESK
in/mortgage/frontend
, you will need to add symlinks:-
to set up: run
make add-bsk-esk-to-mortgage-symlinks
inBSK
-
to teardown: run
make rm-bsk-esk-to-mortgage-symlinks
inBSK
-
to set up: run
- The above commands will create symlinks to
BSK
andESK
in/mortgage/frontend/node_modules
.
-
You will need to create a symlink in
/stylekit/ember-better-stylekit/node_modules/better-stylekit
that points to your localstylekit/src
:-
to set up: run
make add-bsk-to-esk-css-symlink
inBSK
-
to teardown: run
make rm-bsk-to-esk-css-symlink
inBSK
-
to set up: run
-
Stylekit CSS changes should be picked up when you run
npm run build
inBSK
-
If you prefer a watcher, use
npm start
inBSK
- There are visual tests for components. The visual tests work this way:
- build the project, which creates previews of components
- use puppeteer to open the preview html and take a screenshot
- Use node-resemble-js to report any differences between the screenshot and a baseline screenshot
- A diff screenshot will be generated if necessary to highlight issues
- Since screenshots are os/browser dependent, the visual test will only pass in the docker environment
- To run the visual tests invoke
make test
in the root of stylekit - When you add a new component, add a baseline screenshot and enable the component within the visual test
- When you change a component, update the baseline screenshot
- To add or update a baseline screenshot:
- run
make component=yourComponentName generate-baseline
for example:make component=dropdown generate-baseline
- when that command is finished, you should see a new baseline screenshot in
stylekit/src/test/visual/baseline-screenshot
that you can check in
- run
- Patch release:
make release
- Minor release (rare):
make release-minor
- Commit all relevant changes
- Run
npm version patch
ornpm version minor
depending on type of release - Run
npm install
to ensure latest bundled deps are included - Run
npm run build
so the new version is baked in - Commit changes as the new version commit
- Login with
npm login
using the better account (ask someone to share it with you via LastPass) - Run
npm publish
- Ability to add a message to a field
- Generic field set support
- Error state with clearable ability
- Document Field API
- Grid and form component
- Add /index.js and other root-level files to simplify library integration
- React/Preact library integration
- Consider Lerna for monorepo management
- Ember/Preact component generation from one source of truth