-
Notifications
You must be signed in to change notification settings - Fork 0
2. Building a new component
-
Make sure the
design-system/node_modules/@coopdigital
folder contains your new component. -
Add
@import "component-[component-name]/src/[component-name].pcss";
tomain.css
in thedesign-system/src/_css
. -
Add the CSS for your component to
packages/component-[component-name]/src/[component-name].pcss
. -
Create a new page in
design-system/src/pattern-library/examples/components
copied from one of the other examples in the folder. -
Add the mark-up (HTML) for the component into this new file.
-
Navigate to localhost:9000/pattern-library/examples/components/[component-name].html.
-
If everything is correct paste only the mark up (HTML) into
packages/component-[component-name]/src/[component-name].html
. -
Stop the server.
-
Run
NPM run server
- this will copy the HTML into theincludes
folder in Jekyll ready to be used. -
Go to
design-system/src/pattern-library/components...
and create a page based on the ones there to house your component. -
Go to https://be.contentful.com/login and navigate to the design-system space.
-
Select 'Add entry' > design-pattern and create a page for your component.
-
Write the documentation.
-
Publish.
-
Back in your editor stop the server and rerun
NPM run server
- this will get the latest data from Contentful. -
Open
design-system/src/_data/contentful/spaces/design-system-content.yaml
and search for your component's name. -
Copy the ID of the page and paste into your page (from step 11) the ID where you see `{% if designPattern.sys.id == 'XXXXXXXXXXXXXXXXXXXXX' %}'.
-
Change the include file where the HTML and example code is help to match the path to your component. For example:
{% include pattern-library/components/component-card/src/card.html %}
. -
If everything looks good - commit, push to your branch and raise a pull request.
-
Ask for a review from another front-end engineer on the #frontend channel in Slack.
-
If that is merged - check that the build pipeline ran okay.
-
If the pipeline passed you're ready to [https://github.com/coopdigital/coop-frontend/wiki/3.-Publishing-a-component](publish your component to NPM).
-
Your component should be live at https://coop-design-system.herokuapp.com/pattern-library/components/folder-name/component-name.html