Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/LW-6695-staking-…
Browse files Browse the repository at this point in the history
…package-setup
  • Loading branch information
mrcnk committed Jun 5, 2023
2 parents 0b0cf6e + e9071be commit 1009cd5
Show file tree
Hide file tree
Showing 35 changed files with 164 additions and 79 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/packages-staking.yml
Expand Up @@ -40,6 +40,8 @@ jobs:
run: yarn install --frozen-lockfile --non-interactive
- name: Check for linter issues
run: yarn workspace @lace/staking lint
- name: Build dependencies of Staking Center
run: yarn workspace @lace/ui build
- name: Run tests
run: yarn workspace @lace/staking test:unit --coverage
- name: Upload test coverage artifacts
Expand Down
Expand Up @@ -3,7 +3,7 @@ import { Layout } from '@src/views/browser-view/components';
import React from 'react';

const Staking =
process.env.USE_MULTI_DELEGATION_STAKING === 'true' ? require('@lace/staking').Example : require('./Staking').Staking;
process.env.USE_MULTI_DELEGATION_STAKING === 'true' ? require('@lace/staking').Staking : require('./Staking').Staking;

export const StakingContainer = (): React.ReactElement => (
<Layout>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -51,7 +51,7 @@
"prettier --write",
"markdownlint --fix"
],
"packages/staking/package.json": "sort-package-json"
"packages/{staking,ui}/package.json": "sort-package-json"
},
"contributors": [
"Rhys Bartels-Waller <rhys.bartelswaller@iohk.io> (https://iohk.io)"
Expand Down
1 change: 0 additions & 1 deletion packages/staking/.eslintrc.cjs
Expand Up @@ -3,7 +3,6 @@ module.exports = {
node: true,
},
extends: ['prettier'],
ignorePatterns: ['node_modules/**/*'],
overrides: [
{
files: ['src/**/*.d.ts', 'tsup.config.ts', 'vitest.config.ts', '.ladle/*.*'],
Expand Down
12 changes: 12 additions & 0 deletions packages/staking/.ladle/components.tsx
@@ -0,0 +1,12 @@
import { GlobalProvider, ThemeState } from '@ladle/react';
import { ThemeColorScheme, ThemeProvider } from '@lace/ui';
import React, { useMemo } from 'react';

export const Provider: GlobalProvider = ({ children, globalState }) => {
const isLightTheme = useMemo(() => globalState.theme === ThemeState.Light, [globalState.theme]);
return (
<ThemeProvider colorScheme={isLightTheme ? ThemeColorScheme.Light : ThemeColorScheme.Dark}>
{children}
</ThemeProvider>
);
};
2 changes: 2 additions & 0 deletions packages/staking/.ladle/config.mjs
Expand Up @@ -2,6 +2,8 @@ const CWD = process.cwd();

export default {
host: '127.0.0.1',
port: 8080,
previewHost: '127.0.0.1',
previewPort: 8080,
viteConfig: `${CWD}/.ladle/vite.config.ts`,
};
7 changes: 6 additions & 1 deletion packages/staking/.ladle/vite.config.ts
@@ -1,8 +1,10 @@
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import checker from 'vite-plugin-checker';
import eslint from 'vite-plugin-eslint';

export const ladleViteConfig = {
plugins: [
vanillaExtractPlugin(),
checker({
overlay: {
position: 'br',
Expand All @@ -11,7 +13,10 @@ export const ladleViteConfig = {
root: '../',
},
}),
eslint(),
eslint({
include: './**/*',
overrideConfigFile: '.eslintrc.cjs',
}),
],
};

Expand Down
2 changes: 2 additions & 0 deletions packages/staking/.lostpixel/.gitignore
@@ -0,0 +1,2 @@
current
difference
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 0 additions & 14 deletions packages/staking/.stylelintrc.json

This file was deleted.

32 changes: 32 additions & 0 deletions packages/staking/docs/001-structure.md
@@ -0,0 +1,32 @@
# Staking package structure

## Problem

Staking package should have a well described way of splitting the code, based on our past experiences.
The way for the separation of concerns should be easy to understand by any developer reading this codebase.

## Solution

There are numerous ways to split the codebase including:

1. Atomic Design (atoms, molecules, organisms, templates, and views)
2. NextJS-like simple split (components, views)
3. BEM-like splitting (elements, blocks)
4. Flat components directories
5. Feature-based design

We have chosen to go with Feature-based design.
We also discussed combining Feature-based design with Atomic Design, but it seemed to be an overkill.

### Proposed structure

- src
- features
- overview
- OverviewNavigation
- StakingCard
- StakingOverviewView
- index
- StakingView
- StakingView
- index
3 changes: 3 additions & 0 deletions packages/staking/package.json
Expand Up @@ -50,7 +50,9 @@
},
"devDependencies": {
"@ladle/react": "^2.12.3",
"@lace/ui": "^0.1.0",
"@tsconfig/create-react-app": "^1.0.3",
"@vanilla-extract/vite-plugin": "^3.8.2",
"@vitest/coverage-c8": "^0.31.0",
"concurrently": "^8.0.1",
"esbuild-scss-modules-plugin": "^1.1.1",
Expand All @@ -64,6 +66,7 @@
"wait-on": "^7.0.1"
},
"peerDependencies": {
"@lace/ui": "^0.1.0",
"react": "17.0.2",
"react-dom": "17.0.2"
}
Expand Down
4 changes: 0 additions & 4 deletions packages/staking/src/Example.module.scss

This file was deleted.

8 changes: 0 additions & 8 deletions packages/staking/src/Example.stories.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions packages/staking/src/Example.test.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions packages/staking/src/Example.tsx

This file was deleted.

@@ -0,0 +1,19 @@
import type { Story, StoryDefault } from '@ladle/react';
import { OverviewNavigation } from './OverviewNavigation';

export const BasicStory: Story<{ onValueChange: (newValue: string) => void }> = ({ onValueChange }) => (
<OverviewNavigation onValueChange={onValueChange} />
);

BasicStory.argTypes = {
onValueChange: {
action: 'valueChanged',
},
};

const storyDefault: StoryDefault = {
title: 'Overview / Staking Overview Navigation',
};

// eslint-disable-next-line import/no-default-export
export default storyDefault;
14 changes: 14 additions & 0 deletions packages/staking/src/features/overview/OverviewNavigation.tsx
@@ -0,0 +1,14 @@
import { SubNavigation } from '@lace/ui';

type OverviewNavigationProps = Omit<SubNavigation.SubNavigationRootProps, 'children'>;

export const OverviewNavigation = ({ onValueChange, defaultValue = 'overview' }: OverviewNavigationProps) => (
<SubNavigation.Root
aria-label="Staking Overview Navigation"
defaultValue={defaultValue}
onValueChange={onValueChange}
>
<SubNavigation.Item name="Overview" value="overview" />
<SubNavigation.Item name="Browse pools" value="browse" />
</SubNavigation.Root>
);
1 change: 1 addition & 0 deletions packages/staking/src/features/overview/index.ts
@@ -0,0 +1 @@
export { OverviewNavigation } from './OverviewNavigation';
8 changes: 8 additions & 0 deletions packages/staking/src/features/staking/Staking.stories.tsx
@@ -0,0 +1,8 @@
import type { Story } from '@ladle/react';
import { Staking } from './Staking';

export const StakingStory: Story = () => <Staking />;

StakingStory.args = {
test: true,
};
10 changes: 10 additions & 0 deletions packages/staking/src/features/staking/Staking.test.tsx
@@ -0,0 +1,10 @@
import { render } from '@testing-library/react';
import { Staking } from './Staking';

describe('test prop', () => {
it('renders properly', () => {
const { container } = render(<Staking />);

expect(container.textContent).toMatchInlineSnapshot('"StakingOverviewBrowse pools"');
});
});
9 changes: 9 additions & 0 deletions packages/staking/src/features/staking/Staking.tsx
@@ -0,0 +1,9 @@
import { Text } from '@lace/ui';
import { OverviewNavigation } from '../overview';

export const Staking = () => (
<>
<Text.Heading>Staking</Text.Heading>
<OverviewNavigation />
</>
);
1 change: 1 addition & 0 deletions packages/staking/src/features/staking/index.ts
@@ -0,0 +1 @@
export { Staking } from './Staking';
3 changes: 1 addition & 2 deletions packages/staking/src/index.ts
@@ -1,2 +1 @@
export { Example } from './Example';
export type { ExampleProps } from './Example';
export { Staking } from './features/staking';
3 changes: 0 additions & 3 deletions packages/staking/tsup.config.ts
@@ -1,5 +1,3 @@
/* eslint-disable new-cap */
import { ScssModulesPlugin } from 'esbuild-scss-modules-plugin';
import { defineConfig } from 'tsup';

const tsupConfig = defineConfig([
Expand All @@ -8,7 +6,6 @@ const tsupConfig = defineConfig([
clean: true,
dts: true,
entry: ['./src/index.ts'],
esbuildPlugins: [ScssModulesPlugin() as never],
format: ['esm', 'cjs'],
name: 'lace/staking',
outDir: './dist',
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/package.json
@@ -1,6 +1,6 @@
{
"name": "@lace/ui",
"version": "1.0.0",
"version": "0.1.0",
"description": "Lace UI Toolkit",
"repository": {
"type": "git",
Expand Down Expand Up @@ -41,7 +41,7 @@
"@rollup/plugin-commonjs": "20.0.0",
"@rollup/plugin-image": "2.1.1",
"@rollup/plugin-node-resolve": "13.0.4",
"@rollup/plugin-typescript": "8.3.0",
"@rollup/plugin-typescript": "^11.1.1",
"@storybook/addon-actions": "^6.5.16",
"@storybook/addon-essentials": "^6.5.16",
"@storybook/addon-interactions": "^6.5.16",
Expand Down
1 change: 1 addition & 0 deletions packages/ui/rollup.config.js
Expand Up @@ -13,6 +13,7 @@ export default () => ({
typescript({
tsconfig: 'tsconfig.json',
composite: false,
exclude: ['**/*.stories.tsx'],
}),
peerDepsExternal(),
commonjs(),
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/design-system/buttons/skeleton-button.tsx
Expand Up @@ -39,7 +39,9 @@ export const SkeletonButton = ({
>
<Flex alignItems="center" justifyContent="center">
{icon !== undefined && <Flex pr="$8">{icon}</Flex>}
<Text.Button className={className.label}>{label}</Text.Button>
<Text.Button className={className.label}>

Check failure on line 42 in packages/ui/src/design-system/buttons/skeleton-button.tsx

View workflow job for this annotation

GitHub Actions / Build & Test

Replace `⏎··········{label}⏎········` with `{label}`

Check failure on line 42 in packages/ui/src/design-system/buttons/skeleton-button.tsx

View workflow job for this annotation

GitHub Actions / chromatic-deployment

Replace `⏎··········{label}⏎········` with `{label}`
{label}
</Text.Button>
</Flex>
</button>
);
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/design-system/sub-navigation/index.ts
@@ -1,2 +1,3 @@
export { SubNavigation as Root } from './sub-navigation.component';
export { Item } from './sub-navigation-item.component';
export type { SubNavigationRootProps } from './sub-navigation.component';
Expand Up @@ -8,7 +8,7 @@ import * as cx from './sub-navigation.css';
import type { Item } from './sub-navigation-item.component';
import type { OmitClassName } from '../../types';

type Props = OmitClassName & {
export type SubNavigationRootProps = OmitClassName & {
defaultValue?: string;
children: ReactElement<typeof Item> | ReactElement<typeof Item>[];
onValueChange?: (value: string) => void;
Expand All @@ -19,7 +19,7 @@ export const SubNavigation = ({
defaultValue,
onValueChange,
...props
}: Readonly<Props>): JSX.Element => (
}: Readonly<SubNavigationRootProps>): JSX.Element => (
<Tabs.Root
className={cx.root}
defaultValue={defaultValue}
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/index.ts
@@ -1 +1,2 @@
export * from './design-system';
export { ThemeColorScheme, ThemeProvider } from './design-tokens';
2 changes: 1 addition & 1 deletion packages/ui/tsconfig.json
Expand Up @@ -18,7 +18,7 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "ES2016"
"target": "ES2018"
},
"exclude": ["dist"]
}

0 comments on commit 1009cd5

Please sign in to comment.