An open API service indexing awesome lists of open source software.

https://github.com/uselagoon/ui-library

Antd based ui library for all things lagoon related
https://github.com/uselagoon/ui-library

Last synced: 21 days ago
JSON representation

Antd based ui library for all things lagoon related

Awesome Lists containing this project

README

          

# ui-library

A component library based on [Shadcn](https://ui.shadcn.com/) and [tailwind](https://tailwindcss.com/) for all things lagoon related:

## Installation ๐Ÿ’พ

Install it in a React project with a single npm/yarn command:

```bash
npm install github:uselagoon/ui-library#main tailwindcss @tailwindcss/postcss postcss
```

```bash
yarn add github:uselagoon/ui-library#main tailwindcss @tailwindcss/postcss postcss
```

Alternatively, add the following to your `package.json` and run `npm i` / `yarn` command:

```json
"dependencies": {
"react": "^18",
"react-dom": "^18",
"@tailwindcss/postcss": "^4.1.8",
"tailwindcss": "^4.1.10",
"ui-library": "github:uselagoon/ui-library#main",
}

```

Make sure to add generated dist styles from the ui-library like so, preferably in the root layout of your project:

```tsx
import '@uselagoon/ui-library/dist/ui-library.css';
```

## Usage ๐Ÿ”จ

Using a component from the library:

```tsx
import '@uselagoon/ui-library/dist/ui-library.css';
import { Button, SwitchWithDescription } from '@uselagoon/ui-library';

export default () => (
<>
A spooky disabled button

>
```

## Vite config โš™๏ธŽ

The ui-library is bootstrapped with Vite and TS. To modify the configuration, edit `vite.config.ts` in the root directory; To modify TypeScript rules, refer to `tsconfig.app.json`

## Linting and bundling

### Linting ๐Ÿงถ

The linter is configured for both JS and TypeScript files. It runs during the build step but can also be ran during development by `npm run lint`.

To adhere to formatting rules, run `npm run format`.

To configure the linter config, refer to eslint.config.js at the root of the project.

### Bundling ๐Ÿ“ฆ

After making changes to the source files, make sure to run `npm run bundle` command which empties the dist folder and generates updated code for components.

## Viewing storybook ๐Ÿ‘€

- Clone this repo
- Run `npm i && npm run storybook`
- Visit `http://localhost:6006/`

## Development guide ๐Ÿ—๏ธ

Clone the repo locally:

```bash
git clone https://github.com/uselagoon/ui-library .
npm install
npm run storybook
```

It is recommended to build components in isolation with the help of storybook (currently V 9.0).

Open your browser and visit [http://localhost:6006](http://localhost:6006).

The project structure is as follows:

โ”œโ”€โ”€ src
โ”‚ โ”œโ”€โ”€ components # React source code and demos (which then get bundled)
โ”‚ โ”œโ”€โ”€ hooks # Custom hooks
โ”‚ โ”œโ”€โ”€ providers # Custom theme and NextLink providers
โ”‚ โ”œโ”€โ”€ stories # Storybook stories
โ”‚ โ”œโ”€โ”€ index.css # Autogenerated tailwind css file
โ”‚ โ””โ”€โ”€ index.ts # Entrypoint for your `exported` components (that your project then imports)
โ”œโ”€โ”€ eslint.config.js # Eslint config
โ”œโ”€โ”€ vite.config.ts # Vite bundler config
โ””โ”€โ”€ package.json

Given that there's a storybook instance running, navigate to the `src` directory and modify/create new components with their respective `stories.tsx` files.

To add a new component from Shadcn, refer to this [guide](https://ui.shadcn.com/docs/cli)

Modify and customize anything with Tailwind and/or custom css files if needed.

Then run the lint and format scripts, then ultimately, the bundle script and you're ready to go!

```bash
npm run lint
npm run format
npm run bundle
```

## Contributing ๐Ÿค

PRs and issues are welcome, we invite contributions from everyone.

This guide could come in handy: [GitHub contribution guide](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github)