-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Kamil Piwko <[email protected]> Co-authored-by: Katrin Fritz <[email protected]>
- Loading branch information
1 parent
71e0208
commit 9ab35c2
Showing
48 changed files
with
3,358 additions
and
1,572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ node_modules | |
style-dictionary/config.js | ||
storybook-static | ||
dist | ||
coverage | ||
**/*.mdx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ dist-ssr | |
.history | ||
.eslintcache | ||
.env | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ app/javascript/gql/generated.ts | |
app/javascript/shared/i18n.ts | ||
*.ejs | ||
build | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"resolutions": { | ||
"@types/react": "^17.0.10" | ||
"@types/react": "^17.0.10", | ||
"postcss": "^8.4.16" | ||
}, | ||
"name": "betterplace-design-system", | ||
"author": "betterplace <[email protected]>", | ||
|
@@ -25,10 +26,12 @@ | |
"dev": "vite", | ||
"build": "yarn build-tokens && tsc -p tsconfig.base.json && vite build && cp -r ./build/* ./dist/", | ||
"preview": "vite preview", | ||
"prestorybook": "yarn build-tokens", | ||
"storybook": "start-storybook -p 6006", | ||
"figma::tokens": "ts-node -r dotenv/config --project ./tsconfig.tsnode.json figma/fetch_tokens.ts PJ7OUutWRrSHW6qgaPNW1l", | ||
"figma::components": "ts-node -r dotenv/config --project ./tsconfig.tsnode.json figma/fetch_components.ts PJ7OUutWRrSHW6qgaPNW1l", | ||
"component::add::main": "ts-node --project ./tsconfig.tsnode.json node_modules/.bin/yo ./generator --figma --test --story --root src/lib", | ||
"component::add::figma": "ts-node --project ./tsconfig.tsnode.json node_modules/.bin/yo ./generator --figma --test --story --root src/lib", | ||
"component::add::lib": "ts-node --project ./tsconfig.tsnode.json node_modules/.bin/yo ./generator --test --story --root src/lib", | ||
"component::add::local": "ts-node --project ./tsconfig.tsnode.json node_modules/.bin/yo ./generator --root", | ||
"build-storybook": "export BASE_URL='/betterplace-design-system/'; build-storybook", | ||
"build-tokens": "style-dictionary build --config config/style-dictionary/config.js", | ||
|
@@ -40,22 +43,22 @@ | |
}, | ||
"peerDependencies": { | ||
"react": "^17.0.2", | ||
"rxjs": "^7.5.5", | ||
"react-dom": "^17.0.2", | ||
"remotedev": "^0.2.9" | ||
"remotedev": "^0.2.9", | ||
"rxjs": "^7.5.5" | ||
}, | ||
"devDependencies": { | ||
"remotedev": "^0.2.9", | ||
"@babel/core": "^7.17.9", | ||
"@storybook/addon-a11y": "^6.4.22", | ||
"@storybook/addon-actions": "^6.4.21", | ||
"@storybook/addon-essentials": "^6.4.21", | ||
"@storybook/addon-interactions": "^6.4.21", | ||
"@storybook/addon-jest": "^6.4.22", | ||
"@storybook/addon-links": "^6.4.21", | ||
"@storybook/builder-vite": "^0.1.28", | ||
"@storybook/react": "^6.4.21", | ||
"@storybook/testing-library": "^0.0.9", | ||
"@storybook/addon-a11y": "^6.5.12", | ||
"@storybook/addon-actions": "^6.5.12", | ||
"@storybook/addon-docs": "^6.5.12", | ||
"@storybook/addon-essentials": "^6.5.12", | ||
"@storybook/addon-interactions": "^6.5.12", | ||
"@storybook/addon-jest": "^6.5.12", | ||
"@storybook/addon-links": "^6.5.12", | ||
"@storybook/builder-vite": "^0.2.2", | ||
"@storybook/react": "^6.5.12", | ||
"@storybook/testing-library": "^0.0.13", | ||
"@swc/core": "^1.2.189", | ||
"@swc/jest": "^0.2.21", | ||
"@testing-library/jest-dom": "^5.16.4", | ||
|
@@ -69,7 +72,6 @@ | |
"@types/yeoman-generator": "^5.2.10", | ||
"@typescript-eslint/eslint-plugin": "^5.20.0", | ||
"@typescript-eslint/parser": "^5.20.0", | ||
"@vitejs/plugin-react": "^1.0.7", | ||
"babel-loader": "^8.2.4", | ||
"dotenv": "^16.0.0", | ||
"eslint": "^8.13.0", | ||
|
@@ -89,12 +91,15 @@ | |
"jest-css-modules": "^2.1.0", | ||
"jest-environment-jsdom": "^28.1.0", | ||
"lint-staged": ">=10", | ||
"postcss": "^8.4.16", | ||
"postcss-apply": "^0.12.0", | ||
"postcss-nested": "^5.0.6", | ||
"postcss-nesting": "^10.1.7", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"remotedev": "^0.2.9", | ||
"rxjs": "^7.5.5", | ||
"storybook-addon-designs": "^6.2.1", | ||
"storybook-addon-designs": "^6.3.1", | ||
"style-dictionary": "^3.7.0", | ||
"stylelint": "^14.8.1", | ||
"stylelint-config-prettier": "^9.0.3", | ||
|
@@ -105,10 +110,10 @@ | |
"ts-node": "^10.7.0", | ||
"ts-node-register": "^1.0.0", | ||
"typescript": "^4.5.4", | ||
"vite": "^2.9.13", | ||
"vite-plugin-dts": "^1.0.5", | ||
"vite": "^3.1.3", | ||
"vite-plugin-dts": "^1.5.0", | ||
"vite-plugin-dynamic-import": "^0.9.3", | ||
"vite-plugin-eslint": "^1.6.0", | ||
"vite-plugin-eslint": "^1.8.1", | ||
"yeoman-generator": "^5.6.1", | ||
"yo": "^4.3.0" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { PropsWithChildren, useState } from 'react' | ||
import { JSONPrettyPrint } from '../lib/components/json_pretty_print' | ||
|
||
export const HookRenderHelper = ({ children }: PropsWithChildren<Record<string, unknown>>) => { | ||
const [key, setKey] = useState(1) | ||
const [_, setRerender] = useState(1) | ||
|
||
return ( | ||
<div key={key}> | ||
{children} | ||
<hr /> | ||
<div> | ||
<button onClick={() => setRerender((x) => x + 1)}>Rerender Hook</button> | ||
<button onClick={() => setKey((x) => x + 1)}>Remount Hook</button> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export const RenderHook = <T extends (...args: any[]) => any>(hook: T) => { | ||
const name = `${hook.name}[0].toUpperCase()}${hook.name.slice(1)}` | ||
|
||
const Component = (props: Parameters<typeof hook>[0]) => { | ||
const result = hook(props) | ||
return <JSONPrettyPrint json={result} /> | ||
} | ||
Component.displayName = `${name}Demo` | ||
return Component | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './theme_provider' | ||
export * from './hook_render_helper' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './rectangle' | ||
export * from './json_pretty_print' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import JSONPrettyPrint from './json_pretty_print' | ||
export * from './types' | ||
export { JSONPrettyPrint } |
19 changes: 19 additions & 0 deletions
19
src/lib/components/json_pretty_print/json_pretty_print.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.JSONPrettyPrintMain { | ||
padding: 5px; | ||
} | ||
|
||
.string { | ||
color: green; | ||
} | ||
.number { | ||
color: darkorange; | ||
} | ||
.boolean { | ||
color: blue; | ||
} | ||
.null { | ||
color: magenta; | ||
} | ||
.key { | ||
color: red; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/lib/components/json_pretty_print/json_pretty_print.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import { ComponentStory, ComponentMeta } from '@storybook/react' | ||
|
||
import JSONPrettyPrint from './json_pretty_print' | ||
|
||
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export | ||
export default { | ||
title: 'Components/JSON Pretty Print', | ||
component: JSONPrettyPrint, | ||
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes | ||
// argTypes: {}, | ||
} as ComponentMeta<typeof JSONPrettyPrint> | ||
|
||
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args | ||
const Template: ComponentStory<typeof JSONPrettyPrint> = (args) => <JSONPrettyPrint {...args} /> | ||
|
||
export const Default = Template.bind({}) | ||
// More on args: https://storybook.js.org/docs/react/writing-stories/args | ||
Default.args = { | ||
json: { bar: 'Lorem ipsum sic dolor', baz: ['it is a string', { foo: false, sus: null }], bub: 123 }, | ||
} |
16 changes: 16 additions & 0 deletions
16
src/lib/components/json_pretty_print/json_pretty_print.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import JSONPrettyPrint from './json_pretty_print' | ||
import '@testing-library/jest-dom' | ||
|
||
describe('JSON Pretty Print', () => { | ||
it('should correctly render the component', () => { | ||
const test = { a: 1, b: 2, c: [true, { e: 'var' }] } | ||
const { container } = render(<JSONPrettyPrint json={test} />) | ||
const element = container.querySelector('.JSONPrettyPrintMain') | ||
expect(element).toBeTruthy() | ||
}) | ||
}) |
Oops, something went wrong.