@unimelb/pattern-lib-vue v15.2.3
Pattern Library
Copyright © 2017 - The University of Melbourne
The contents of this repository have been produced by The University of Melbourne for internal use and must not be distributed without the express permission of The University of Melbourne.
- Development Preview (Netlify deploy from
devbranch) - Production (Netlify deploy from
masterbranch)
External usage
- How to use the library - how this library externally
Getting started
The design system requires:
# 1. Clone the repository.
git clone https://github.com/unimelb/pattern-lib.git
# 2. Enter your newly-cloned folder.
cd pattern-lib
# 3. Copy the env file.
cp .env.example .env
# 4. Copy the git pre-push hook
cp pre-push.sh .git/hooks/pre-push
# 4. Install dependencies. Make sure yarn is installed: https://yarnpkg.com/lang/en/docs/install
yarn
# 5. Read the documentation linked below.Development
Storybook is the main development environment.
yarn dev- http://localhost:7002/yarn buildto build the documentation site to/.out/docs. Environment variableLOAD_EXTERNAL_ASSETScontrols whether the documentation site is to load the library assets locally (false) or from the CDN (true).
Generator
This project includes generators to speed up common development tasks. Commands include:
# Generate a new component
yarn generate componentYou will then be asked for the name of the component, this will be used to create a new folder with a minimal component layout and story
Note: Always remember to add the new component to the file
index.jsinside of the folderstarget/libandtarget/vue, that way the component will be exportable toMatrix CMSviaCDNandVueviaNPM.
# Generate a new view component
yarn generate storyYou will need to select the component from the list of folders, then confirm the selection by selecting choose this directory. You will then be asked to give the story a name.
Note: This requires some special comments are added in the
stories/index.jsfile. If it doesn't work make sure the comments are the same as in the template directory.
Using a component in CMS
In Storybook: When adding the "how to use a component" documentation, add a description that clearly shows that ( in the CMS environment) a component must be used in the way of closing the tag explicitly, as shown in the following example:
Do not:
(In the CMS, self closing tags won't load the component:)
# self close the components
<my-new-component/>Do
(To be compatible with CMS, call the component this way:)
# explicitly closing
<my-new-component></my-new-component>Note: Matrix CMS can only use the components in that way and must be in the
target/libfolder as well. You can self-close a component when importing it in a parent component in the pattern-lib context. The rule described above applies just when the component is called in the CMS context. ie. footer component, which is used like this in CMS:<page-footer-alt></page-footer-alt>instead of<page-footer-alt />.
Targets
UI library - targets/lib
The main UI library for use in the CMS. The target provides a local development environment for testing purposes.
yarn start:lib- http://localhost:7003/.yarn build:libto compile the library to.out/lib/<version>, includingui.css,ui.js,sprite.svg, and SVG assets incomponents/shared. You can then usehttp-serveror another static file server to serve the output directory.
The following environment variables are available to configure the behaviour of yarn build:lib:
LOAD_EXTERNAL_ASSETScontrols whether the library is to load its assets locally (false) or from the CDN (true).LIB_EMIT_HTMLcontrols whether to emit the demo HTML file - set it totrueto emit the file.LIB_LOAD_VERSIONcontrols which version of the library to load in the demo:- leave it blank to load the local bundles (e.g. to test a new feature),
- set it to
autoto load the latest version from the CDN (i.e. the version specified inpackage.json), - set it to a specific version number to load that version from the CDN - e.g.
0.0.12(novprefix).
Vue library - targets/vue
The library with all the Vue components for use in single-page apps and other Vue-based projects.
yarn build:vueto compile the library to.out/vue.js.
Linting
CSS files are linted on the fly with stylelint. The configuration file, .stylelintrc, extends two shared configuration: stylelint-config-standard and stylelint-config-property-sort-order-smacss.
JS files and single-file Vue components are linted on the fly with ESLint. The configuration file, .eslintrc, extends two shared configurations: eslint-config-airbnb and plugin:vue/recommended
For your own sanity, make sure to install your code editor's ESLint and stylelint extensions. The following commands are available for on-demand linting and fixing:
yarn lintyarn lint:fixyarn lint:cssyarn lint:css --fixyarn lint:jsyarn lint:js --fix
Release process
At the start of a new release sprint:
- Create a milestone called
next-release.
Throughout the release sprint:
- Assign the appropriate
pr-label to every new PR:pr-majorif it contains a breaking change,pr-minorif it adds a new feature,pr-patchin all other cases. - Assign issues and PRs to
next-releaseas they are resolved/merged. - Assign additional labels to issues when relevant (e.g.
deprecated,documentation, etc.)
At the end of the release sprint:
!NOTE > Note on versioning: the version number follows the semver convention
MAJOR.MINOR.PATCH, where:MAJORcorresponds to a breaking change (e.g. a change in a component's markup),MINORto a new feature (e.g. a new component, a new feature for an existing component, etc.), andPATCHto a bug fix or under-the-hood change (e.g. code clean-up, performance improvement, etc.)
- Look at all the PRs that were assigned to
next-releasethroughout the sprint and identify the highest-level of change (major, minor or patch). Deduce the next release's version number and rename the milestone accordingly. - Create a new release notes draft based on the following template:
.github/RELEASE_NOTES_TEMPLATE.md. - Write the release notes by going through all the issues and PRs assigned to the milestone.
- Deploy to production:
- Bump the
versionnumber inpackage.json(cf. note below). - Commit the version change to the
devbranch. - Create a pull request to merge the
devbranch intomaster- e.g. "Deploy v1.0.1". - Wait for the mandatory checks to pass then select
Create a merge commit
- Bump the
- Once the library and documentation sites are deployed, publish the release notes and close the milestone.
- Share the release on the
design-systemsslack channel using the following template:
@channel new `gen2` version `vx.x.x` is out: https://github.com/unimelb/pattern-lib/releases/tag/vx.x.x!TIP Github Actions then automatically builds the library and syncs the output files to S3. If the version you're deploying had been previously deployed, you'll need to invalidate the files on the CDN (AWS Cloudfront) or wait a day or so for this to happen automatically. Once the library is deployed, follow the release process below.
Semi-automatic deployment to dev
Pre-release builds can be created like this (using the git pre-push hook behind the scenes):
!NOTE > Note on pre-release versions: These are legitimate semver versions. They have the format MAJOR.MINOR.PATCH-beta.NUMBER. Only these pre-release versions will be published on
dev.
- Check out a clean
devbranch - in bash
git push- this will increment the pre-release version number and make a commit to your local repository - in bash
git pushagain- You will be prompted that this will trigger a build. Answer
y - This will push (only) your version number change commit to the remote
devrepo
- You will be prompted that this will trigger a build. Answer
- After the normal checks a build with the new version will be triggered by Github Actions
Testing
Testing Pull-requests
You can test pull-requests on live sites by using ?preview=test-xxx where xxx is the pull-request number.
For example: https://study.unimelb.edu.au/?preview=test-2203 will load https://github.com/unimelb/pattern-lib/pull/2203
How could you test before going live?
Code changes to the remote
devbranch triggers aGithub Actionsdeploy into the AWS S3 Bucket in a folder calledlatestwhere theCMSteam can appoint tolatestand test it out before go toproduction.Each
pull requestthat is opened, also is automatically generated a comment with a preview link to test it.Note: Always check
Github Actionsin yourpull requestchecks to insure it is building properly, before merge intodev.
Supported browsers:
- last two versions of Chrome, Firefox and Edge
- IE 11
- Safari 8+
- iOS 8.4+
- Android 4.4+
- Firefox ESR (v52.x)
Recommended mobile devices for testing:
- iPhone 4S
- iPhone 6
- iPad 2
- Galaxy s5
Visual snapshot testing
You can run visual snapshot testing using yarn test:snapshots. This compares your changes against the latest visual snapshot. Failed snapshot tests will show a visual diff comparison in snapshots/__tests__/__image_snapshots__/__diff_output__.
If you wish to update the snapshots with your changes run yarn test:e2e:updatesnapshots.
Visual Regression Tests
!IMPORTANT These tests should be run
exclusivelyon yourlocalmachine to detect visual regressions before merging yourpull-request.
You can test your changes against live production sites to ensure nothing breaks.
- uses
TEST_PREVIEW_IDlocated in.env- refer toenv.example - the list of production sites are located in
/e2e/tests/regression/pages.json
Running regression tests
- update your regression snapshots
!TIP Make sure to comment out
TEST_PREVIEW_IDto use thedevbranch as thebasesnapshots. Alternatively, you can use anypull-requestid.
yarn test:update:regression- set the
TEST_PREVIEW_IDto your desiredpull-requestid - run the regression tests to compare your
pull-requestagaints the base snapshots
yarn test:regression- view the report
yarn test:reportDeveloper documentation
- Documenting stories - how to customise the content of the README panel for each story
- Icons - how to add new icons, and how to use icons in CSS and Vue components
- Contributing - how to get involved and contribute code
Example websites
The following UoM websites are using these components on the new Squiz CMS (Gen 2). Documentation on how to use these components in Edit+ Gen 2 documentation
- About Us
- Brand Hub
- MSpace
8 months ago
8 months ago
9 months ago
10 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago