Crayons is a component library based on Web Components. The goal of Crayons is to provide developers with easy to use web components that give apps a Freshworks product like user interface, while reducing the number of lines of code. Crayons is developed using StencilJS that helps build standard-based Web Components.
Crayons has a predefined set of components. As a developer, you not only can use the components in your projects but you can also contribute to Crayons, as it falls under the MIT license. We welcome all contributions, big or small.
Crayons uses monorepo
setup. There are 3 packages under packages folder. Uses Lerna for managing monorepo along with npm workspaces.
- crayons-core (All core atomic components are present here)
- crayons-icons (icon library for crayons)
- crayons-i18n (i18n Library for crayons)
- Forking and setting up
- Raising issues towards the repo
- Fixing an existing issue
- Creating a new component/ changes to other packages
Note : Please use npm instead of yarn
- Go to utilities -> Terminal -> Right click and click "get info" and enable "Open using rosetta" which uses x64 arch instead of native arm64 and Use Terminal Rosetta further
- Do fresh install of node and NPM as mentioned below and follow other steps
- Node Engine requirements
- Node: >=14.7.0
- NPM: >=7.0.0
- Fork the Crayons repository.
- Clone your forked Crayons repository.
git clone https://github.com/freshworks/crayons
- Change directory to the cloned repository and install all the dependencies using
npm ci
. - Run
npm run build
to make sure all packages are in sync. - Run
git config core.hooksPath .git/hooks/
. - To install/uninstall any new dependency for a package , use
npm install / uninstall <<dependency>> --workspace=<<packagename>>
. You can find the name of the workspace under each package's package.json. cd packages/crayons-core
andnpm run start
will start the dev server. You can make changes insrc/index.html
to see live changes in the browser.npm run test
to run the test- To build storybook / docs site, go to root folder and run npm run build.
Docs site -> www-dist, Storybook -> docs/storybook-dist
- Always run
npm run build
from root folder before commiting changes so that readme files are in sync. - You can generate a component by running
npm run generate
inpackages/crayons-core
directory. scss
variables and mixins are present instyles
folder.
When generating components, the custom element tags is prefixed with fw-
while the rest of the name is modified to support web component standards. For example, if a component is generated with the name Label
, the component that would be generated would be <fw-label/>
.
- master - stable release branch
- next - experimental pre-release branch (default)
To know about the release process check here
If you find an issue or if you want to raise a feature request in, make sure you raise an issue in https://github.com/freshworks/crayons/issues
Should you choose to work on a new issue or an existing issue from https://github.com/freshworks/crayons/issues, please follow the steps below.
- Make the required changes to the component.
- Write integrations tests and unit tests.
- Check for all lint errors, if there are any fix them.
- Run tests for all the components.
- If the component you modify is used in another component make sure you update the tests for that component as well.
- Raise a Pull Request to the Crayons Repository.
The Crayons repository uses GitHub's pre-commit hooks. To commit your changes,
-
Make your changes to the files and add the untracked files to the staging area.
-
Run
git commit
. -
Choose one of the following based on the nature of your commit.
Type Description feat A new feature fix A bug fix docs Documentation only changes style Changes that do not affect the meaning of the code(white-space, formatting, missing semi-colons, etc) refactor A code change that neither fixes a bug nor adds a feature perf A code change that improves performance test Adding missing tests or correcting existing tests build Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) ci Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) chore Other changes that don't modify src or test files revert Reverts a previous commit -
Choose the scope of the change.
? What is the scope of this change (e.g. component or file name): (press enter to skip)
-
Give a brief description for the commit.
? Write a short, imperative tense description of the change (max 94 chars):
-
Give a long description for the commit.
? Provide a longer description of the change: (press enter to skip)
-
Fill in the following details when prompted.
? Are there any breaking changes? Yes ? Describe the breaking changes: documents ? Does this change affect any open issues? No
-
Give a commit message when prompted.
-
Run
git push -u origin <your-branch>
, to push your changes to the forked repo. git hooks will run all the test before pushing the changes. if any test fails, rewrite the tests and ensure that all tests pass before pushing again. -
Go to the forked repo in github and raise a PR against
next
branch. If there are any comments on your PR, address them. Please wait for the PR to be approved.
Q: Githooks are not running on my repo. What do I do?
Ans: Please run git config core.hooksPath .git/hooks/
in the root of your project.