Skip to content

Commit

Permalink
link local dependencies: storybookjs/storybook#11255
Browse files Browse the repository at this point in the history
  • Loading branch information
charkour committed Jan 31, 2021
1 parent 3c97c23 commit 06b4545
Show file tree
Hide file tree
Showing 11 changed files with 7,241 additions and 235 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ lib
*.bs.js
.bsb.lock
*.gen.tsx
storybook-static
6 changes: 3 additions & 3 deletions packages/harmoniously-react/example/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'react-app-polyfill/ie11';
import * as React from 'react';
import 'react-app-polyfill/ie11';
import * as ReactDOM from 'react-dom';
import { Thing } from '../.';
import { Harmony } from '.././src/index';

const App = () => {
return (
<div>
<Thing />
<Harmony />
</div>
);
};
Expand Down
6,933 changes: 6,933 additions & 0 deletions packages/harmoniously-react/example/package-lock.json

Large diffs are not rendered by default.

488 changes: 272 additions & 216 deletions packages/harmoniously-react/package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions packages/harmoniously-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
},
"dependencies": {
"canvas-confetti": "1.3.2",
"harmoniously": "*"
"harmoniously": "^0.1.0"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@size-limit/preset-small-lib": "^4.9.1",
"@storybook/addon-essentials": "^6.1.14",
"@storybook/addon-essentials": "^6.1.15",
"@storybook/addon-info": "^5.3.21",
"@storybook/addon-links": "^6.1.14",
"@storybook/addons": "^6.1.14",
"@storybook/react": "^6.1.14",
"@storybook/addon-links": "^6.1.15",
"@storybook/addons": "^6.1.15",
"@storybook/react": "^6.1.15",
"@types/canvas-confetti": "1.3.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
Expand Down
10 changes: 7 additions & 3 deletions packages/harmoniously-react/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import confetti from 'canvas-confetti';
import { Assignments, harmony } from 'harmoniously';
import React, { FC, HTMLAttributes, ReactChild } from 'react';

export interface Props extends HTMLAttributes<HTMLDivElement> {
/** custom content, defaults to 'the snozzberries taste like snozzberries' */
children?: ReactChild;
assignments?: Assignments;
}

// Please do not use types off of a default export module or else Storybook Docs will suffer.
// see: https://github.com/storybookjs/storybook/issues/9556
/**
* A custom Thing component. Neat!
*/
export const Thing: FC<Props> = ({ children }) => {
export const Harmony: FC<Props> = ({ children, assignments }) => {
const res = assignments && harmony(assignments, undefined, undefined);
console.log(res);

return (
<>
<div>{children || `the snozzberries taste like snozzberries`}</div>
<div>{children}</div>
<button
onClick={() =>
confetti({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import { Meta, Story } from '@storybook/react';
import { Thing, Props } from '../src';
import React from 'react';
import { Harmony, Props } from '../src';

const meta: Meta = {
title: 'Welcome',
component: Thing,
component: Harmony,
argTypes: {
children: {
control: {
Expand All @@ -19,10 +19,10 @@ const meta: Meta = {

export default meta;

const Template: Story<Props> = args => <Thing {...args} />;
const Template: Story<Props> = (args: Props) => <Harmony {...args} />;

// By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
// https://storybook.js.org/docs/react/workflows/unit-testing
export const Default = Template.bind({});
export const Default = Template.bind({ children: 'Hi' });

Default.args = {};
6 changes: 3 additions & 3 deletions packages/harmoniously-react/test/blah.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import * as ReactDOM from 'react-dom';
import { Default as Thing } from '../stories/Thing.stories';
import { Default as Harmony } from '../stories/Harmony.stories';

describe('Thing', () => {
describe('Harmony', () => {
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<Thing />, div);
ReactDOM.render(<Harmony />, div);
ReactDOM.unmountComponentAtNode(div);
});
});
5 changes: 5 additions & 0 deletions packages/harmoniously-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,10 @@
"forceConsistentCasingInFileNames": true,
// `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc`
"noEmit": true,
// Use to load local dependents
"baseUrl": ".",
"paths": {
"harmoniously": ["../harmoniously/dist"]
}
}
}
6 changes: 6 additions & 0 deletions packages/harmoniously/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/harmoniously/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"devDependencies": {
"@size-limit/preset-small-lib": "^4.9.1",
"core-js": "3.8.3",
"husky": "^4.3.7",
"size-limit": "^4.9.1",
"tsdx": "^0.14.1",
Expand Down

0 comments on commit 06b4545

Please sign in to comment.