This project contains the Ontario Design System Web Components and npm packages.
Web Components provide strong encapsulation for reusable components that can be integrated into web applications.
The Ontario Design System components are an implementation of the best practices of the Ontario Design System.
- Visit our Component Developer Documentation for more information about the npm packages and each available component.
- Visit our Ontario Design System Guidance for more information about the Ontario Design System, our best practices, and other design system features.
Stencil is a toolchain for building reusable, scalable Design Systems.
Learn more in the Stencil Docs.
Using Lerna, this project is made up of multiple packages that are linked together, called a monorepo. Lerna takes care of bootstrapping the packages within this repository together with their dependencies. It will install the node_modules
for each package, then link the internal project packages together.
The fastest way to hit the ground running is to run,
npm install # Install install the root packages
npm run refresh # Ready the project for development
Note: The refresh
script encompass cleaning, bootstrapping, and building of all the core Ontario Design System npm packages within the repository.
Firstly, Lerna needs to be installed at the root level of the project.
At the repository root run,
npm install
Next, each repository needs to be bootstrapped to setup and link all the dependencies.
While at repository root run,
npm run bootstrap
The ontario-design-system
packages are all designed to be published as npm packages. In order to do any development, or to just build the project in general, the packages have to be built/updated before they can be used.
Simply run at the root of the repository,
npm run build-libs
This will build the packages that are marked as public and prep them for use with any app.
Checkout each package in the packages
folder. They each have their own Readme and instructions on how to get started.
This project is made up of five packages.
Wanting to build and test within one of the framework applications? Running the build-libs
script from the root triggers this behaviour.
The library can be built independently by running,
npm run build
Content coming soon.
Wanting to build and test within one of the framework applications? Running the build-libs
script from the root triggers this behaviour.
The library can be built independently by running,
npm run build
The ontario-design-system-component-library
is the heart of the project, it contains each of the the custom web components. It uses the Stencil toolchain to allow for easy creation and compilation of custom components.
The build process of this library emits npm package compatible packages as well as component libraries for other JavaScript UI Frameworks.
Wanting to build and test within one of the framework applications? Running the build-libs
script from the root triggers this behaviour.
The library can be built independently by running,
npm run build
The project contains an HTML file called index.html
that is immediately loaded when the development server is started it. It is a simple place to stage a component for development.
A development server can be run by running,
npm run start
Stencil CLI can generate a new component within the src/components
folder. With the ontario-design-system-component-library
being your current directory run,
stencil generate name-of-component
If you don't have stencil
installed globally, prefix the command with npx
,
npx stencil generate name-of-component
The ontario-design-system-component-library-react
package is a React wrapper for custom web components generated by the ontario-design-system-component-library
. It handles all the boilerplate code to wrap the components for import into any React app. Material emitted from the ontario-design-system-component-library
build process is injected into this process every time there is a new build made within that package.
See the Stencil Docs on React for more information.
Note: This library doesn't currently support Next.js Server-Side Rendering. For now, use use client
in wrappers around the components.
Wanting to build and test within one of the framework applications? Running the build-libs
script from the root triggers this behaviour.
The library can be built independently by running,
npm run build
The ontario-design-system-component-library-angular
package is a Angular wrapper for custom web components generated by the ontario-design-system-component-library
. It handles all the boilerplate code to wrap the components for import into any React app. Material emitted from the ontario-design-system-component-library
build process is injected into this process every time there is a new build made within that package.
See the Stencil Docs on Angular for more information.
Wanting to build and test within one of the framework applications? Running the build-libs
script from the root triggers this behaviour.
The library can be built independently by running,
npm run build
A React frontend to show off the whole process, from ontario-design-system-component-library
components to React components. It is a simple Create React App application and demos the simplicity of using the generated components.
The application can be run in development by running,
npm run start
The application can be build for production by running,
npm run build
A Angular frontend to show off the whole process, from ontario-design-system-component-library
components to Angular components. It is a simple Angular application and demos the simplicity of using the generated components.
The application can be run in development by running,
npm run start
The application can be build for production by running,
npm run build
Built using Docusaurus, this package contains the React based documentation platform for easy deployment of the npm package and web components component documentation.
The documentation is sourced from the npm packages Readme files, as well as the Readme files of each component. To populate the documentation see the Quick Start section or each package section about building the package.
To update the documentation, simply rebuild the libraries and then re-run the development server.
The application can be run in development by running,
npm run start
This will start a development server that can be used to test out changes to the documentation.
The application can be build for production by running,
npm run build
Each package, as well as the root of the repository, contain package.json
scripts to clean up each package/project.
The clean
script is used to clean up any build artefacts that might be produced. It should not touch any installed dependencies and is good for making sure the builds build cleanly. Try this is you're running into any weird, non package related build issues.
In any project, or at the root of the repository run,
npm run clean
If run at the root of the repository Lerna will execute each package's clean
script, allowing the entire project to be cleaned up.
The clean:full
script is used to clean any build artefacts as well as nuke the package's node_modules
folder. For a non module clean see clean
.
In any project, or at the root of the repository run,
npm run clean:full
If run at root this will run the clean:full
script on each package, which will clean build artefacts and nuke the node_modules
directory. The root level node_modules
directory will not be touched. This makes sure that Lerna is left around.
Here are some helpful resources one can use to learn more.