-
Notifications
You must be signed in to change notification settings - Fork 2
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
refactor: card header file organisation and descriptionRadio story #3842
Conversation
Removed vultr server and associated DNS entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very much in favour or tidy ups and organisations like this 🙌
One suggestion - it might be a little cleaner to use an index.ts
for the main file in a module? So in this PR /CardHeader/CardHeader.ts
which holds the main component would become /CardHeader/index.ts
This would let us use import syntax like this -
import { CardHeader } from "@planx/components/shared/Preview/CardHeader";
I think one of the nicest benefits from this approach is that it essentially forces us to be a bit more strict in having a folder with a single "main" component, alongside associated styles.ts
, types.ts
etc
Thanks Daf! I have updated the file to not use a default export so that we can import in the way you suggested As for renaming the file to But I guess the trade off is having the path name complicated by the double |
Hey there, sorry for the slow reply here and for holding you up. It's a very fair point - we're sort of in this world of less meaningful file names already with a lot of I did think of suggesting the use of barrell files which is the the pattern that Bulletproof React uses - this repo is always a reliable touchpoint I find. This would give meaningful filenames and terse imports. Here's an example - https://github.com/alan2207/bulletproof-react/blob/master/apps/react-vite/src/components/ui/form/index.ts Sidenote - I really want to talk properly about restructuring and rationalising the React app a lot so let's come back to this one as a template! However, it turns out Vite specifically says not to follow this pattern, so I'd say this is a no-go as an option - https://vite.dev/guide/performance#avoid-barrel-files 🙃 I think this is one is worth opening up to the wider dev team (asap so we're not blocking!) but I'm leaning towards your proposal here which favours DX and bundling here over any other option 👍 |
Another minor refactor that results in a large PR 😅
All I've done is split up
CardHeader.tsx
into smaller files (e.g.styled
andtypes
) and this has changed a lot of imports.One other change in this PR is adding a storybook file for
descriptionRadio
as I was wondering if it would be useful for the upcoming feedback component work. I'm probably not going to use it in the end but still thought plugging storybook gaps might be useful!