Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(repo): shared ui lib #17021

Merged
merged 52 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8e43906
created svelte lib package
bearni95 May 6, 2024
a044235
storybook scaffolding
bearni95 May 6, 2024
2d75386
storybook cleanup
bearni95 May 6, 2024
b5f64f2
dirty but functional scaffolding on storybook + svelte + tailwind
bearni95 May 7, 2024
943ab16
lib export working properly
bearni95 May 7, 2024
63e3f31
test install for lib in taikoon-ui
bearni95 May 7, 2024
5803954
adding missing commit files
bearni95 May 7, 2024
a019d04
ui lib packaged + footer
bearni95 May 8, 2024
13f593a
readme
bearni95 May 8, 2024
02288e6
added link onto svelte+storybook docs
bearni95 May 8, 2024
1d25e9a
Merge branch 'main' into ui-lib
bearni95 May 14, 2024
82158c3
forge fmt & update contract layout table
bearni95 May 14, 2024
2c4c8b9
forge fmt & update contract layout table
bearni95 May 14, 2024
3399cd1
fixed fonts on storybook
bearni95 May 14, 2024
b98020f
removed autodocs from storybook
bearni95 May 14, 2024
9949571
restored configs for storybook constrols
bearni95 May 14, 2024
6e4dfd4
Merge branch 'ui-lib' of ssh://github.com/taikoxyz/taiko-mono into ui…
bearni95 May 14, 2024
be33a01
refreshed pnpm-lock.yaml
bearni95 May 14, 2024
bc5b2b2
Merge branch 'main' into ui-lib
bearni95 May 14, 2024
5b79b7c
example export/import of lib's tailwind config; fully ported footer o…
bearni95 May 15, 2024
d2e5269
support for light/dark theme switch
bearni95 May 15, 2024
ad36303
scaffolding for color theme exports
bearni95 May 15, 2024
103b9e7
non-theme colors imported
bearni95 May 15, 2024
9d74253
colors and themes included
bearni95 May 16, 2024
4c97906
updated pnpm-lock.yml
bearni95 May 16, 2024
0c33637
Merge branch 'main' into ui-lib
bearni95 May 16, 2024
5c337bb
revert docs involuntary changes
bearni95 May 16, 2024
5cda3ad
reverted protocol changes
bearni95 May 16, 2024
dfd82df
reverting more lefthook auto changes
bearni95 May 16, 2024
14e89b2
Merge branch 'main' into ui-lib
bearni95 May 16, 2024
d4ad089
gha updates
bearni95 May 16, 2024
c24a874
added storybook build step
bearni95 May 16, 2024
b6eddd8
format & lint
bearni95 May 16, 2024
1b078f8
gha to build ui-lib for taikoon-ui
bearni95 May 16, 2024
162068e
Merge branch 'main' into ui-lib
bearni95 May 16, 2024
56d58a7
Merge branch 'ui-lib' of ssh://github.com/taikoxyz/taiko-mono into ui…
bearni95 May 16, 2024
c3b27da
properly included ui-lib build command for taikoon-ui builds
bearni95 May 16, 2024
91672d3
discord color update
bearni95 May 16, 2024
190ad4e
updated release-please
bearni95 May 16, 2024
5bb8acb
reverted changes to taikoon-ui
bearni95 May 16, 2024
84e7644
reverted validate-pr-title
bearni95 May 16, 2024
728530d
Merge branch 'main' into ui-lib
bearni95 May 17, 2024
9788854
refreshed pnpm-lock.yaml
bearni95 May 17, 2024
c81245c
improved docs
bearni95 May 17, 2024
ef51579
renamed ui lib package
bearni95 May 17, 2024
a75d7e0
Merge branch 'main' into ui-lib
bearni95 May 17, 2024
3b100ab
Merge branch 'main' into ui-lib
bearni95 May 20, 2024
a55d8a6
Merge branch 'main' into ui-lib
bearni95 May 20, 2024
aa9a08d
Merge branch 'main' into ui-lib
bearni95 May 20, 2024
e34bb2c
Merge branch 'main' into ui-lib
bearni95 May 20, 2024
0850611
restored protocol changes
bearni95 May 20, 2024
b1cd97a
Merge branch 'main' into ui-lib
bearni95 May 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/ui-lib--ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: UI Lib Build and Checks

on: workflow_call

jobs:
build:
runs-on: [taiko-runner]
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}

- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install pnpm dependencies
uses: ./.github/actions/install-pnpm-dependencies

- name: Svelte build
working-directory: ./packages/ui-lib
run: pnpm build

- name: Storybook build
working-directory: ./packages/ui-lib
run: pnpm build-storybook

- name: Svelte check
working-directory: ./packages/ui-lib
run: pnpm check

- name: Check formatting
working-directory: ./packages/ui-lib
run: pnpm lint

- name: Unit tests
env:
SKIP_ENV_VALIDATION: "true"
working-directory: ./packages/ui-lib
run: pnpm test:unit
752 changes: 386 additions & 366 deletions packages/protocol/contract_layout.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/protocol/script/DeployOnL1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ contract DeployOnL1 is DeployCapability {
impl: address(new TaikoToken()),
data: abi.encodeCall(
TaikoToken.init, (owner, vm.envAddress("TAIKO_TOKEN_PREMINT_RECIPIENT"))
),
),
registerTo: sharedAddressManager
});
}
Expand Down Expand Up @@ -266,7 +266,7 @@ contract DeployOnL1 is DeployCapability {
vm.envBytes32("L2_GENESIS_HASH"),
vm.envBool("PAUSE_TAIKO_L1")
)
),
),
registerTo: rollupAddressManager
});

Expand Down Expand Up @@ -325,7 +325,7 @@ contract DeployOnL1 is DeployCapability {
impl: automateDcapV3AttestationImpl,
data: abi.encodeCall(
AutomataDcapV3Attestation.init, (owner, address(sigVerifyLib), address(pemCertChainLib))
),
),
registerTo: rollupAddressManager
});

Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/test/bridge/Bridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ contract BridgeTest is TaikoTest {
impl: address(new DelegateOwner()),
data: abi.encodeCall(
DelegateOwner.init, (mockDAO, address(addressManager), l1ChainId)
)
)
})
)
);
Expand Down
13 changes: 13 additions & 0 deletions packages/ui-lib/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
32 changes: 32 additions & 0 deletions packages/ui-lib/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/** @type { import("eslint").Linter.Config } */
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier',
'plugin:storybook/recommended'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
};
13 changes: 13 additions & 0 deletions packages/ui-lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/dist
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
/storybook-static
*storybook.log
1 change: 1 addition & 0 deletions packages/ui-lib/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
5 changes: 5 additions & 0 deletions packages/ui-lib/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
storybook-static
8 changes: 8 additions & 0 deletions packages/ui-lib/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
29 changes: 29 additions & 0 deletions packages/ui-lib/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { StorybookConfig } from '@storybook/sveltekit';

export const framework = {
name: '@storybook/sveltekit',
options: {}
};

export const docs = { autodocs: false };
export const addons = [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@chromatic-com/storybook',
'@storybook/addon-interactions',
'@storybook/addon-themes'
];

const config: StorybookConfig = {
//framework: '@taiko/ui-lib',
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
staticDirs: ['../static'],
framework: {
name: '@storybook/sveltekit',
options: {}
},
addons,
docs
};

export default config;
31 changes: 31 additions & 0 deletions packages/ui-lib/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { Preview } from '@storybook/svelte';
import { withThemeByDataAttribute } from '@storybook/addon-themes';
import '../src/lib/styles/app.css';

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i
}
}
},

tags: ['autodocs']
};

/* snipped for brevity */

export const decorators = [
withThemeByDataAttribute({
themes: {
light: 'light',
dark: 'dark'
},
defaultTheme: 'light',
attributeName: 'data-theme'
})
];

export default preview;
71 changes: 71 additions & 0 deletions packages/ui-lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Taiko UI Library

## Components

- [x] Footer
- [ ] Icons
- [ ] Button
- [ ] ResponsiveController

## Exported values

- [x] UI Kit colors
- [x] Dark Theme colors
- [x] Light Theme colors
- [ ] Typography

## Contributing

### Development

The library includes [Storybook](https://storybook.js.org/) for development. To start the Storybook server, run:

```bash
$ pnpm storybook
```

### Build

The library builds and packs as a [Svelte library] with the following command:

```bash
$ pnpm build
```

### Adding components

In order to add new components into the library to be used outside:

1. Create a new component under `src/lib/components/` directory.
2. Export the component on `src/lib/index.ts`:

```typescript
import { NewComponent } from './components/NewComponent';

export {
Footer,
...
NewComponent
};

```

3. Now you can import it and use it in another project:

```typescript
import { NewComponent } from '@taiko/ui-lib';

...

<NewComponent />
```

### Exported values

Besides from the components, the library exports the configurations for TailwindCSS in `src/theme/`:

- `colors.js`: [Taiko's UI Kit](https://www.figma.com/design/3zuVeAbGDICzyhVvSI15nG/Taiko---UI-Kit-%26-Components?node-id=26-122&t=R6fMNiuhGixl6nxX-0) core colors
- `dark-mode.js`: TailwindCSS/DaisyUI dark mode configuration
- `light-mode.js`: TailwindCSS/DaisyUI light mode configuration

All exported values from the `src/theme` directory are prefixed with `tko-` to avoid conflicts with other libraries and local definitions.
82 changes: 82 additions & 0 deletions packages/ui-lib/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"name": "@taiko/ui-lib",
"version": "0.0.1",
"type": "module",
"engines": {
"node": ">=20"
},
"scripts": {
"dev": "vite dev",
"build": "vite build && npm run package",
"preview": "vite preview",
"package": "svelte-kit sync && svelte-package && publint",
"prepublishOnly": "npm run package",
"test": "npm run test:integration && npm run test:unit",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check ./src && eslint ./src --fix",
"format": "prettier --write .",
"test:integration": "playwright test",
"test:unit": "vitest",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"svelte": "./dist/index.js",
"main": "./dist/index.js"
},
"./tailwind": "./tailwind.config.js"
},
"files": [
"tailwind.config.js",
"dist",
"!dist/**/*.test.*",
"!dist/**/*.spec.*"
],
"peerDependencies": {
"svelte": "^4.0.0"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.3.4",
"@playwright/test": "^1.28.1",
"@storybook/addon-essentials": "^8.0.10",
"@storybook/addon-interactions": "^8.0.10",
"@storybook/addon-links": "^8.0.10",
"@storybook/addon-themes": "^8.1.1",
"@storybook/blocks": "^8.0.10",
"@storybook/svelte": "^8.0.10",
"@storybook/sveltekit": "^8.0.10",
"@storybook/test": "^8.0.10",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/package": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "^8.56.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"autoprefixer": "^10.4.19",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-storybook": "^0.8.0",
"eslint-plugin-svelte": "^2.35.1",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"publint": "^0.1.9",
"storybook": "^8.0.10",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tailwindcss": "^3.4.3",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.11",
"vitest": "^1.2.0"
},
"svelte": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {
"daisyui": "^4.11.1",
"tailwindcss-image-rendering": "^1.0.2"
}
}
12 changes: 12 additions & 0 deletions packages/ui-lib/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173
},
testDir: 'tests',
testMatch: /(.+\.)?(test|spec)\.[jt]s/
};

export default config;
6 changes: 6 additions & 0 deletions packages/ui-lib/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};