2.16.0 โ€ข Published 7 months ago

@synanetics/syn-library v2.16.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

SYN-library

โญ Getting started

This project uses node 20

Run npm ci to set up the packages required.

Run npm run build to build the project.

Run npm run storybook to view the UI libraries Storybook documentation.

๐Ÿฆ‹ Changesets

This project uses changesets to manage the changelog, versioning and publishing to npm. A changeset is a small file that records a change and helps automate versioning.

To create a changeset, run npx changeset after making a change.

This will prompt you to specify the type of change (follow semantic versioning):

  • Patch: For backwards compatible bug fixes
  • Minor: For adding functionality in a backwards compatible manner
  • Major: For incompatible API changes (breaking changes)

You will then be asked for a summary that will be included in the changelog. This should include the Jira reference with the following structure:
[[ABC-123](https://synanetics.atlassian.net/browse/ABC-123)] Description of change

A changeset file will be created within the .changeset directory. Ensure that this file is committed and pushed as part of your PR.

Versioning and Publishing

The SYN-library is published to the @synanetics npm repo.

  1. When a PR with a changeset is merged into the main branch, the GitHub release workflow automatically creates a new PR titled "Version Packages". This PR will:
    • Remove processed changeset files
    • Update the changelog
    • Bump the package version based on the changes
  2. Once the 'Version Packages' PR is merged, the GitHub release workflow will run again, which publishes the new package version to npm automatically.

๐ŸŒ€ Publishing to Chromatic

The storybook is published on Chromatic

This should be done as part of the chore task that updates the published version so that the published storybook matches the current npm package.

You can redeploy locally or in CI with npm run chromatic.

โ„น The project token was added to the script via the --project-token flag. If you're running Chromatic via continuous integration, we recommend setting the CHROMATIC_PROJECT_TOKEN environment variable in your CI environment. You can then remove the --project-token from your package.json script.

We should perhaps do this!

๐Ÿ–ผ๏ธ Icons

The library's icons predominantly come from Google's Material Symbols and Icons.

Adding a new icon

  1. Ensure the icon has been added to the SYN Library's Figma Icon's.
  2. On Figma, right click the icon you want to add. You should see a purple 20 x 20 bounding box appear around it.
  3. Select Copy as > Copy as SVG.
  4. Create a file in the src/icons folder with your new icon name. It should follow the existing file name convention, [Name]Icon.tsx.
  5. A standard icon should receive at least one prop, size. This number will dictate the height and width of the icon.

Use the following template to structure your icon:

import React from "react"

import { IconProps } from "./IconProps"

export const MyIcon = ({ size = 20 }: IconProps) => {
  return (
    <svg fill="none" height={size} viewBox="0 0 20 20" width={size} xmlns="http://www.w3.org/2000/svg">
      {*/ <mask> */}
      {*/ <g> */}
    </svg>
  )
}
  1. Your <svg> will likely have a <path> tag within it, with the fill attribute having a hardcoded hex value (likely to be #1E2428). Change this to fill="currentColor".
  2. Export your new icon from the icon folder's barrel file, src/icons/index.ts
  3. Viewing the Icons story on Storybook should show all icons, including your new one.
  4. Scroll to the bottom of the icon's Storybook page and change the color value using the colour wheel. Your icon should change colour.

๐Ÿ’ป Local Project Development

You can simultaneously develop this library alongside another local project.

  1. Navigate to the root directory of this UI library and run npm link.
  2. Go to the root directory of your local project and run npm link @synanetics/syn-library.
  3. Remember to run npm run build in the library if you make any changes, to ensure your project is using the latest version. Updates should be reflected in your local project immediately.

You will need to re-link the packages if you install other dependencies at any point during local development.

You want to unlink the local instance of the package via:

npm unlink --no-save @synanetics/syn-library

If you have made changes to the UI library and errors occur similar to the following:

SyntaxError: The requested module ABC does not provide an export named 'xyz'

Restarting WSL and VS Code will likely resolve this issue.

๐Ÿงช Testing

React Testing Library, Jest & Axe

Each component has a corresponding [Name].test.tsx within it's folder.

React Testing Library is combined with jest-axe to run unit tests and prevent accessibility errors.

To manually run all tests, run npm run test:unit.

Playwright

Playwright is used for integration tests.

Running Playwright tests

Run npm run test:integration

โš™๏ธ Installing and Usage

  1. Install via npm i @synanetics/syn-library
  2. At your applications root scss file, import the core SCSS file via @use "@synanetics/syn-library/core";
  3. Import the desired theme SCSS file using one of the following:

Synanetics: @use "@synanetics/syn-library/synanetics" BCU: @use "@synanetics/syn-library/bcu" Interweave: @use "@synanetics/syn-library/interweave" NHS (WIP): @use "@synanetics/syn-library/nhs"

  1. Ensure the fonts are installed for each theme by adding the correct link to the html head.

Synanetics: Zilla Slab, Nirmit BCU: Calibri Interweave: Nunito, Open sans NHS (WIP): Arial

  1. Then, anywhere in your application, you can import the required components e.g. import { Button } from "@synanetics/syn-library";
2.11.0

8 months ago

2.2.0

9 months ago

2.4.0

9 months ago

2.6.1

8 months ago

2.6.0

8 months ago

2.8.1

8 months ago

2.8.0

8 months ago

2.0.0

10 months ago

2.15.0

7 months ago

2.13.0

7 months ago

1.3.0

10 months ago

2.3.0

9 months ago

2.12.0

8 months ago

2.5.0

9 months ago

2.10.0

8 months ago

2.7.0

8 months ago

2.5.2

8 months ago

2.5.1

9 months ago

2.9.0

8 months ago

2.1.0

10 months ago

2.8.2

8 months ago

2.16.0

7 months ago

2.12.1

7 months ago

2.14.0

7 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.0

11 months ago

1.0.0

11 months ago

0.26.2

11 months ago

0.26.1

11 months ago

0.25.1

1 year ago

0.25.0

1 year ago

0.23.13

1 year ago

0.23.12

1 year ago

0.23.15

1 year ago

0.23.14

1 year ago

0.24.5

1 year ago

0.24.4

1 year ago

0.24.3

1 year ago

0.26.0

1 year ago

0.24.2

1 year ago

0.24.1

1 year ago

0.24.0

1 year ago

0.24.8

1 year ago

0.24.7

1 year ago

0.23.11

1 year ago

0.23.10

1 year ago

0.23.9

1 year ago

0.23.8

1 year ago

0.23.6

1 year ago

0.23.7

1 year ago

0.23.5

1 year ago

0.23.4

1 year ago

0.23.3

1 year ago

0.23.2

1 year ago

0.23.1

1 year ago

0.23.0

1 year ago

0.22.2

1 year ago

0.22.1

1 year ago

0.22.0

1 year ago

0.21.0

1 year ago

0.20.0

1 year ago

0.19.0

1 year ago

0.18.0

1 year ago

0.17.0

1 year ago

0.16.0

1 year ago

0.15.0

1 year ago

0.14.0

1 year ago

0.13.0

1 year ago

0.12.0

1 year ago

0.11.0

1 year ago

0.10.0

1 year ago

0.9.0

1 year ago

0.8.0

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago