Coder Social home page Coder Social logo

westpacgel / gel-next Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 4.0 13.07 MB

Design System for Westpac

Home Page: https://gel.westpacgroup.com.au

JavaScript 0.41% Shell 0.02% TypeScript 69.07% CSS 0.14% Handlebars 0.07% Roff 30.30%
design-system accessibility

gel-next's Introduction

Getting Started

This section describes how to get started with Westpac GEL.

What is GEL?

The Global Experience Language is our single source of truth, providing everything you need to deliver our brand promises and create consistent, coherent customer experiences across our entire digital landscape faster, and with less effort.

You can read more about GEL in https://gel.westpacgroup.com.au/articles/what-is-GEL

Pre-requisites

All GEL components have a couple of dependencies so please ensure the following are installed:

npm i react@^18.2.0
npm i -D tailwindcss@~3.3.2 postcss autoprefixer

GEL is using Tailwind for styling. Visit the Tailwind docs to learn more about installation and usage.

Installation

GEL can be installed using a package manager like npm, yarn or pnpm.

npm i @westpac/ui

Update tailwind.config.js to use the withGEL helper exported by @westpac/ui as follows.

import { withGEL } from '@westpac/ui/tailwind';

/** @type {import('tailwindcss').Config} */
const config = withGEL({
  relative: true,
  content: ['./src/**/*.{js,ts,jsx,tsx,mdx}', './node_modules/@westpac/ui/src/**/*.{js,ts,jsx,tsx,mdx}'],
  safelist: [],
});

export default config;

Also, you have to create a postcss.config.js on the root of your application as follows.

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};

For applications using brand fonts add the following options config to the withGEL helper.

const config = withGEL({
  relative: true,
  content: ['./src/**/*.{js,ts,jsx,tsx,mdx}', './node_modules/@westpac/ui/src/**/*.{js,ts,jsx,tsx,mdx}'],
  safelist: [],
  options: {
    brandFonts: {
      src: '/fonts', // path to font files
      brands: ['wbc', 'stg'], // takes a single brand string e.g. 'wbc' or an array of brands. If no brands are specified will import all brands by default
    },
  },
});

Ensure tailwind directives are added to your main CSS file.

@tailwind base;
@tailwind components;
@tailwind utilities;

If you have initialized your project with Nx build system follow the official Nx tailwind documentation to configure tailwind. Nx based projects requires __dirname prefix to the paths in the tailwind.config.js file and postcss file.

Usage

Using brands

Add a custom attribute tag data-theme="brand_name" to html tag. Note that instead of adding the custom attribute to html tag, you can add it to the parent tag of your application as well.

Following example shows adding wbc theme. You can add other valid brand names such as stg, bom, bsa, rams, wbg etc. as the value.

<!doctype html>
<html lang="en" data-theme="wbc">
  ...
</html>

NOTE: There are some components that use portals Modal, BottomSheet, AutoComplete. These components will default their portal to where you add your data-theme attribute tag so these components can make use of branding. This can be overridden using their portalContainer props if you require the portal to be located elsewhere.

Now you can start using the GEL components in your React.js application. The following examples show how to use the Button component.

For detailed documentation refer to https://gel.westpacgroup.com.au/design-system.

Individual package import

We recommended the individual package import approach if you have issues with Tree shaking.

import { Button } from '@westpac/ui/button';

export default function SampleApp() {
  return (
    <section>
      <div className="space-x-4 mb-2">
        <Button look="primary">Pay here</Button>
      </div>
    </section>
  );
}

Mono package import

Modern bundlers like Vite and latest webpack will automatically detect the individual components and only bundle the components you use.

However, use this approach with caution as it may cause issues with Tree shaking since not all bundlers have this advanced capability.

import { Button } from '@westpac/ui';

export default function SampleApp() {
  return (
    <section>
      <div className="space-x-4 mb-2">
        <Button look="primary">Pay here</Button>
      </div>
    </section>
  );
}

Unit testing

We recommend Vitest for unit testing since Vitest natively supports ES modules.

If you are using Jest for unit testing, you might encounter some issues since Jest does not support ES modules by default. Therefore, you will need to make following configuration changes.

Update the package.json file if you have initialized your project with Create React App.

{
  "scripts": {
    "test": "node scripts/test.js --transformIgnorePatterns \"node_modules/(?!(@westpac/ui)/)\""
  }
}

Update the jest.config.js file if you have initialized your project with Nx build system and Babel.

{
   transform: {
     '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/react/babel'] }]
   },
   transformIgnorePatterns: ['node_modules/(?!@westpac/ui)']
}

Documentation

Visit https://gel.westpacgroup.com.au/design-system to view the full documentation.

Contributing to GEL

Developing

  • The development branch is develop.
  • All pull requests should be opened against develop.
  • The changes on the develop branch are published to the preview environment.

To develop locally (common for all the packages and apps)

  1. Install Node.js 18.x or above. We recommend https://github.com/nvm-sh/nvm to install Node.js.

  2. Clone the Next.js repository:

    git clone --single-branch --branch develop [email protected]:WestpacGEL/GEL-next.git
    
  3. Create a new branch:

    git checkout -b MY_BRANCH_NAME origin/develop
    
  4. Enable pnpm:

    corepack enable pnpm
    
  5. Install the dependencies with:

    pnpm install
    
  6. Start developing and watch for code changes:

    pnpm dev
    
  7. Run the unit tests with:

    pnpm test
    
  8. Fix formatting and linting with:

    pnpm format:fix && pnpm lint:fix
    
  9. Check formatting and linting with:

    pnpm format && pnpm lint
    
  10. Check TypeScript compatibility with:

pnpm check-types
  1. You can build packages and apps with:
pnpm build
  1. You can add a changeset with:
pnpm changeset
To develop a GEL UI component locally
  1. Change the working directory with:
    cd packages/ui
    
  2. Create a new GEL component with:
    cd packages/ui
    pnpm generate:component
    
  3. Start storybook with:
    pnpm build && pnpm storybook
    
  4. Run the unit tests in watch mode with:
    pnpm test:watch
    
    When your changes are finished, commit them to the branch and push it to origin.

gel-next's People

Contributors

katemacdonald avatar samithaf avatar kenjishiromajp avatar tomjackking avatar jaortiz avatar tomkingwestpac avatar github-actions[bot] avatar justinspencer avatar dependabot[bot] avatar totaland avatar

Stargazers

WWC avatar Nuwan Chandrasoma avatar  avatar Luke Bennett avatar Long Dang avatar Terry Xu avatar  avatar Alex Chiu avatar

Watchers

Jed Watson avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gel-next's Issues

Button - As Link

Not sure if I'm doing something wrong but example doesn't look like it has button link styling applied.

Not Button Link Styling

Repeater and Separator

Removing an item always removes the last item in the list no matter which remove button you press. This happens on both Repeater and Separator. @KateMacdonald or am I missing something?

Remove.mov

Accordion component

Colours:
The text for this component seems to be using the Westpac Brand Text colour (#181b25) regardless of the Theme that is displaying.

Naming:
There shouldn't be a 'Primary' version of this component, we have one coloured version in Hero which is called Lego
There also shouldn't be a version where you can choose the colour.

Checkbox group - Selected tick

The tick in GEL-next is too thick and doesn't match the tick in the current GEL. FYI. It would be good to reduce the weight of these ticks to better match the icon style. Let me know if this is possible and I'll provide a design.

Next - Not correct GEL - Correct

Gel docs update

Design and Accessibility tab (has to integrate with content block to be consumed in keystatic)

Pagination arrows moving

I'm not aware of the use-cases for this component however, Ideally the arrows shouldn't move when clicked. See movie attached.

Pagination.arrow.moves.mov

Autocomplete No Options display and icon rendering

  1. The "No Options" prompt is not displayed as per the current GEL. See screen grab attached.
  2. I'm noticing rendering issues with the icons. The icon in the error message should be 12px. It's drawn on the pixel grid so it should be super sharp and not distorted as shown in the screen grab attached. Note: this also happens in the current GEL. Chrome and Safari.
Autocomplete no no opions Autocomplete icon issue Autocomplete no options

Accordion Open and Close Transistion

The open and close transition on the Accordion fades the content while the item is opening or closing. This leads to an overlap of content during the animation which is incorrect. See screen grab attached.

The preferred action is to mask the containing content as shown in the current GEL implementation. See screen grab attached.

Not correct Correct

Verify component interface is align with the component implementation

Looks like in some cases component interface is not properly align with the actual component implementation. E.g. as per typings we can define the title of Accordion.Item as React.ReactNode but React Aria only supports a string.

We will need to go through each component and verify and I am not sure how to automate these findings.

Input field icon colours

Out of the box I think all icons in input fields should be Muted. @KateMacdonald is this correct?

On another note... Do icons in Input fields have colour options and what are the UX rules around clickable vs none clickable icons?

Input icon colours

Alert text wrapping and icon clipping

In XS the text is not wrapping correctly and (in Safari) the top of the icon is clipping. (See screen grab attached)
Please see current GEL application for correct implementation. Also if possible please provide examples with more content as this will ensure that we can test for these scenarios.
Alert xs

The GRID

Not sure what's going on here but it's not how the grid works.

Every break point has a specific gutter width and margins. When the grid (columns) reach a max width of 1200px the grid is set to a fixed width and centred in the viewport.

The best demonstration of the GRID is the one we created in GUI 2.0 (See link below). However, please note the margins have increased in Xs since we did this and we've also added the Xsl breakpoint. I've attached a video showing how the grid responds to different viewport sizes.

https://gel.westpacgroup.com.au/GUI/WBC/templates/

Screenshot 2023-10-24 at 12 43 37 pm
The.Grid.demo.mov

Tailwind developer docs

GEL Tailwind Plugin contains, Westpac specific font sizes, spacing etc ( aka tokens ). We need to document it so consumers know the available tokens

Checkbox group - focus state displayed on a mouse event

In the original GEL Dom added a small piece of JavaScript to ensure that the browser focus state was only rendered when the using the keyboard. I'm not sure if a decision has been reversed however the current GEL still seems to implement it.

Checkbox focus state

Compacta remove button

This is more of a UX requirement.
When there is only one compacta it should not display the remove button. When an additional item is added all items must display a remove button.

Compacta wrong Compacta correct

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.