42
loading...
This website collects cookies to deliver better user experience
I will do this manually though I recommend that if your monorepo is supposed to be used by many developers and hold many components, you should have a sort of a package generator for it, so that the packages created are aligned and the dev experience is good.
cd packages/components && yarn init
@pedalboard
namespace, add Jest and Eslint as dev dependencies and mark its publish config as “public” (so it will not inherit the root project’s “private” configuration). Here is how my package.json looks like now:{
"name": "@pedalboard/components",
"version": "0.0.0",
"description": "A set of well-crafted components",
"main": "index.js",
"author": "Matti Bar-Zeev",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "echo \"Still no test specified\" && exit 0",
"lint": "eslint ./src"
},
"devDependencies": {
"eslint": "^8.4.1",
"jest": "^27.4.3"
}
}
Yarn add react react-dom -P
npx sb init
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
It appears that new versions of Storybook have an issue with react and react-dom as peer dependencies. The current suggestions I found was to either put these dependencies in the dependencies section of the package.json or downgrade the version of Storybook. Let's admit it, both suck. I tried something and it seems to be working - in the components package react and react-dom are still peer dependencies, but on the monorepo's root project I have them as dependencies. Yeah, I think that this is a less horrible solution...
Yarn storybook
import React from 'react';
import Pagination from '../Pagination';
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
export default {
title: 'Example/Pagination',
component: Pagination,
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
argTypes: {
onPageChange:{ action: 'Page changed' },
},
};
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
const Template = (args) => <div><Pagination {...args} /></div>;
export const Simple = Template.bind({});
// More on args: https://storybook.js.org/docs/react/writing-stories/args
Simple.args = {
pagesCount:10,
cursor:3,
pagesBuffer:5,
};
eslint-plugin-react
plugin to the package’s dev dependenciesyarn add eslint-plugin-react -D
{
"env": {
"browser": true,
"commonjs": true
},
"extends": ["eslint:recommended", "plugin:react/recommended"],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {}
}
feat: Add the first component to the components package
- uses: actions/checkout@v2
with:
fetch-depth: 0