@vandebron/windmolen
v18.4.1
Published
Vandebron's styleguide for web
Downloads
920
Maintainers
Keywords
Readme
How to install
Run the following command using npm
npm install @vandebron/windmolen
If you prefer Yarn, use the following command instead
yarn add @vandebron/windmolen
Demo
A storybook reference of the component library can be found here windmolen.netlify.com . Hosted on Netlify.
Usage
Import the CSS file
Note: it is necessary to do this step otherwise the styles will not be applied, you can import it into the project entry point.
import '@vandebron/windmolen/dist/index.css';
Now you can import the components that you want to use:
import { Container, H1, Paragraph } '@vandebron/windmolen';
Development
Link another repository for live testing
It can be very helpful to see your changes to Windmolen components directly reflected in another project you're working on. To set this up you should follow the following steps.
- Set this package folder as source for your yarn symlink connection
yarn link
- Go to the project where you'd like to consume this package and run:
yarn link @vandebron/windmolen
- And finally, start the Windmolen bundler in watch mode
yarn start
Note:
this can be unlinked again with yarn unlink
and yarn unlink @vandebron/windmolen
Additional note:
After replacing webpack with Vite there may be issues when sym-linking Windmolen with the apps projects within the Vandebron monorepo. If you encounter issues and you are not seeing your changes you can try the following:
- Go to
apps/config/vite.config.base.ts
in the Vandebron monorepo. - Update the
fs.allow
array. Add the relative path to your local Windmolen repository as a new entry. For instance, if you have both Windmolen and the monorepo repositories contained within the same root folder, the path will look like'../../../windmolen'
. - Add a new property
optimizeDeps
to the root level of config:optimizeDeps: { include: ['@vandebron/windmolen'] }
- Make sure you do not commit these changes!. They must be reset once you have finished your testing.
Work on Storybook stories
When changing stories in Storybook you might want to see your changes reflected directly. To do so run the Storybook development server that will run locally with
yarn storybook
Tests and verification
The repository knows three methods to guard code quality.
yarn types
- will initiate a TS compiler typecheckyarn lint
- will analyze the code based on the set linting rulesyarn test
- will start the Jest test runner, which mostly works with automatically generated tests
All of these stages are invoked before any git push and can also be triggered manually with the command
yarn verify
Publishing
Storybook
Storybook is automatically build based on the HEAD
version on the master
branch. Any push made there will trigger a new build on Netlify.
Windmolen
To publish a new version of the Windmolen package, first merge your branch to master. Next, pull master on your local machine and then run the following commands:
# Use the appropriate version bump. See https://semver.org/ for details
./deploy.py (major|minor|patch)
# You will require publishing rights on NPM for this
npm publish
git push && git push --tags
Alpha or Beta releases
If you want to deploy an Alpha or Beta version do the following:
npm version prerelease --preid=(alpha|beta)
npm publish --tag (alpha|beta)
For example, if you want to bump the version from 3.2.0 to an alpha release of the next patch version (i.e. 3.2.1), you would do the following:
npm version prerelease --preid=alpha
npm publish --tag alpha
Creating a new icon
To create a new icon you must follow these steps:
Exporting from Figma
- Find the icon in the 'Design System' file on Figma
- From a design, you can follow a link to the design system from the 'Inspect' tab in the right side bar
- Select the icon in the libary
- Make sure you have selected the most upper layer of the icon
- In the sidebar on the right, select the 'Export' tab and export to SVG
- You can use the preview to see if you selected the right thing
Optimizing SVG
- Go to https://jakearchibald.github.io/svgomg/
- Click on
Paste markup
and paste the SVG code - Enable the "Prefer viewBox to width/height" feature in the menu on the right side of the page
- The
viewBox
attribute was previously added manually, this is not necessary when the aforementioned feature is enabled
- The
- The icon will be rendered, click on the
Copy as text
button (it's above the download button) - Go to your prefered text editor and paste the code
- Change all
fill=
andstroke=
attributes that have a specific color tocurrentColor
, so that the final result is e.g.fill="currentColor"
.- Leave any attribute that is set to
none
, for examplestroke="none"
since that part of the image is probably meant to be empty
- Leave any attribute that is set to
Adding the icon to the project
- Create a new SVG file inside
src/assets/icons
, remember that the icon's name will be the name that you will use after to use it. (p.s:my-new-icon.svg
will be<Icon name="my-new-icon" />
) - Run the following command to convert the SVG icons into react components.
node scripts/convert-icons.js
- Update
src/components/Icon/icons.ts
using the name of the new icon.