-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
build: support tsx components and storybook #1564
Changes from 11 commits
59c6629
6689ad5
c5ec43e
107d3dd
c9e2ff5
1e83f82
a514a01
1396e81
ce3d3bd
17e6570
f87e920
b4eb289
432ba63
6b84ae2
7886600
a23223e
79397e2
3cfe181
492f591
2a50714
fdce6c0
8c668d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,6 @@ | |
|
||
# electron build | ||
dist | ||
|
||
# design system ts output | ||
/src/js/components/**/*.js | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reason, I my git is recognizing unstaged changes in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's your version of git? Recursive glob support was only added in 1.8.2. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2.25.1. Can look into it and add my repro steps. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems fine now. But There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignored |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
"stories": [ | ||
"../src/js/**/*.stories.mdx", | ||
"../src/js/**/*.stories.tsx" | ||
], | ||
"addons": [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials" | ||
], | ||
webpackFinal: async (config, { configType }) => { | ||
// Always prefer .tsx files when resolving modules. | ||
// We output the .js files from tsc directly on the same folder, but want | ||
// storybook to process the original .tsx for the additional TS tooling. | ||
config.resolve.extensions.unshift(".tsx"); | ||
|
||
// Return the altered config. | ||
return config; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
export const parameters = { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
} | ||
|
||
const cssVars = ` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed with Stuart how this is duplication of code in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would we want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about the whole of athens.style, but at least part of it yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah just the part that is all the CSS properties. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The style generation for Storybook has been implemented in my current branch here, shanberg@dca0688, but is not yet used in the app. |
||
:root { | ||
--background-color---opacity-high: hsla(0, 0%, 10.196078431372548%, 0.75); | ||
--background-color---opacity-higher: hsla(0, 0%, 10.196078431372548%, 0.85); | ||
--background-color---opacity-low: hsla(0, 0%, 10.196078431372548%, 0.25); | ||
--background-color---opacity-lower: hsla(0, 0%, 10.196078431372548%, 0.1); | ||
--background-color---opacity-med: hsla(0, 0%, 10.196078431372548%, 0.5); | ||
--background-color: #1A1A1A; | ||
--background-minus-1---opacity-high: hsla(0, 0%, 8.235294117647058%, 0.75); | ||
--background-minus-1---opacity-higher: hsla(0, 0%, 8.235294117647058%, 0.85); | ||
--background-minus-1---opacity-low: hsla(0, 0%, 8.235294117647058%, 0.25); | ||
--background-minus-1---opacity-lower: hsla(0, 0%, 8.235294117647058%, 0.1); | ||
--background-minus-1---opacity-med: hsla(0, 0%, 8.235294117647058%, 0.5); | ||
--background-minus-1: #151515; | ||
--background-minus-2---opacity-high: hsla(0, 0%, 6.6667%, 0.75); | ||
--background-minus-2---opacity-higher: hsla(0, 0%, 6.6667%, 0.85); | ||
--background-minus-2---opacity-low: hsla(0, 0%, 6.6667%, 0.25); | ||
--background-minus-2---opacity-lower: hsla(0, 0%, 6.6667%, 0.1); | ||
--background-minus-2---opacity-med: hsla(0, 0%, 6.6667%, 0.5); | ||
--background-minus-2: #111; | ||
--background-plus-1---opacity-high: hsla(0, 0%, 13.333%, 0.75); | ||
--background-plus-1---opacity-higher: hsla(0, 0%, 13.333%, 0.85); | ||
--background-plus-1---opacity-low: hsla(0, 0%, 13.333%, 0.25); | ||
--background-plus-1---opacity-lower: hsla(0, 0%, 13.333%, 0.1); | ||
--background-plus-1---opacity-med: hsla(0, 0%, 13.333%, 0.5); | ||
--background-plus-1: #222; | ||
--background-plus-2---opacity-high: hsla(0, 0%, 20%, 0.75); | ||
--background-plus-2---opacity-higher: hsla(0, 0%, 20%, 0.85); | ||
--background-plus-2---opacity-low: hsla(0, 0%, 20%, 0.25); | ||
--background-plus-2---opacity-lower: hsla(0, 0%, 20%, 0.1); | ||
--background-plus-2---opacity-med: hsla(0, 0%, 20%, 0.5); | ||
--background-plus-2: #333; | ||
--body-text-color---opacity-high: hsla(0, 0%, 66.666%, 0.75); | ||
--body-text-color---opacity-higher: hsla(0, 0%, 66.666%, 0.85); | ||
--body-text-color---opacity-low: hsla(0, 0%, 66.666%, 0.25); | ||
--body-text-color---opacity-lower: hsla(0, 0%, 66.666%, 0.1); | ||
--body-text-color---opacity-med: hsla(0, 0%, 66.666%, 0.5); | ||
--body-text-color: #AAA; | ||
--border-color---opacity-high: hsla(0, 0%, 0%, 0.75); | ||
--border-color---opacity-higher: hsla(0, 0%, 0%, 0.85); | ||
--border-color---opacity-low: hsla(0, 0%, 0%, 0.25); | ||
--border-color---opacity-lower: hsla(0, 0%, 0%, 0.1); | ||
--border-color---opacity-med: hsla(0, 0%, 0%, 0.5); | ||
--border-color: hsla(32, 81%, 90%, 0.08); | ||
--confirmation-color---opacity-high: hsla(133.43283582089555, 73.62637362637363%, 35.68627450980392%, 0.75); | ||
--confirmation-color---opacity-higher: hsla(133.43283582089555, 73.62637362637363%, 35.68627450980392%, 0.85); | ||
--confirmation-color---opacity-low: hsla(133.43283582089555, 73.62637362637363%, 35.68627450980392%, 0.25); | ||
--confirmation-color---opacity-lower: hsla(133.43283582089555, 73.62637362637363%, 35.68627450980392%, 0.1); | ||
--confirmation-color---opacity-med: hsla(133.43283582089555, 73.62637362637363%, 35.68627450980392%, 0.5); | ||
--confirmation-color: #189E36; | ||
--error-color---opacity-high: hsla(4.838709677419331, 97.89473684210527%, 62.745098039215684%, 0.75); | ||
--error-color---opacity-higher: hsla(4.838709677419331, 97.89473684210527%, 62.745098039215684%, 0.85); | ||
--error-color---opacity-low: hsla(4.838709677419331, 97.89473684210527%, 62.745098039215684%, 0.25); | ||
--error-color---opacity-lower: hsla(4.838709677419331, 97.89473684210527%, 62.745098039215684%, 0.1); | ||
--error-color---opacity-med: hsla(4.838709677419331, 97.89473684210527%, 62.745098039215684%, 0.5); | ||
--error-color: #fd5243; | ||
--graph-control-bg---opacity-high: hsla(0, 0%, 15.294117647058824%, 0.75); | ||
--graph-control-bg---opacity-higher: hsla(0, 0%, 15.294117647058824%, 0.85); | ||
--graph-control-bg---opacity-low: hsla(0, 0%, 15.294117647058824%, 0.25); | ||
--graph-control-bg---opacity-lower: hsla(0, 0%, 15.294117647058824%, 0.1); | ||
--graph-control-bg---opacity-med: hsla(0, 0%, 15.294117647058824%, 0.5); | ||
--graph-control-bg: #272727; | ||
--graph-control-color---opacity-high: hsla(0, 0%, 0%, 0.75); | ||
--graph-control-color---opacity-higher: hsla(0, 0%, 0%, 0.85); | ||
--graph-control-color---opacity-low: hsla(0, 0%, 0%, 0.25); | ||
--graph-control-color---opacity-lower: hsla(0, 0%, 0%, 0.1); | ||
--graph-control-color---opacity-med: hsla(0, 0%, 0%, 0.5); | ||
--graph-control-color: white; | ||
--graph-link-normal---opacity-high: hsla(0, 0%, 19.607843137254903%, 0.75); | ||
--graph-link-normal---opacity-higher: hsla(0, 0%, 19.607843137254903%, 0.85); | ||
--graph-link-normal---opacity-low: hsla(0, 0%, 19.607843137254903%, 0.25); | ||
--graph-link-normal---opacity-lower: hsla(0, 0%, 19.607843137254903%, 0.1); | ||
--graph-link-normal---opacity-med: hsla(0, 0%, 19.607843137254903%, 0.5); | ||
--graph-link-normal: #323232; | ||
--graph-node-hlt---opacity-high: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.75); | ||
--graph-node-hlt---opacity-higher: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.85); | ||
--graph-node-hlt---opacity-low: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.25); | ||
--graph-node-hlt---opacity-lower: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.1); | ||
--graph-node-hlt---opacity-med: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.5); | ||
--graph-node-hlt: #FBBE63; | ||
--graph-node-normal---opacity-high: hsla(0, 0%, 56.470588235294116%, 0.75); | ||
--graph-node-normal---opacity-higher: hsla(0, 0%, 56.470588235294116%, 0.85); | ||
--graph-node-normal---opacity-low: hsla(0, 0%, 56.470588235294116%, 0.25); | ||
--graph-node-normal---opacity-lower: hsla(0, 0%, 56.470588235294116%, 0.1); | ||
--graph-node-normal---opacity-med: hsla(0, 0%, 56.470588235294116%, 0.5); | ||
--graph-node-normal: #909090; | ||
--header-text-color---opacity-high: hsla(0, 0%, 72.94117647058823%, 0.75); | ||
--header-text-color---opacity-higher: hsla(0, 0%, 72.94117647058823%, 0.85); | ||
--header-text-color---opacity-low: hsla(0, 0%, 72.94117647058823%, 0.25); | ||
--header-text-color---opacity-lower: hsla(0, 0%, 72.94117647058823%, 0.1); | ||
--header-text-color---opacity-med: hsla(0, 0%, 72.94117647058823%, 0.5); | ||
--header-text-color: #BABABA; | ||
--highlight-color---opacity-high: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.75); | ||
--highlight-color---opacity-higher: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.85); | ||
--highlight-color---opacity-low: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.25); | ||
--highlight-color---opacity-lower: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.1); | ||
--highlight-color---opacity-med: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.5); | ||
--highlight-color: #FBBE63; | ||
--link-color---opacity-high: hsla(203.8775510204082, 80.32786885245902%, 52.156862745098046%, 0.75); | ||
--link-color---opacity-higher: hsla(203.8775510204082, 80.32786885245902%, 52.156862745098046%, 0.85); | ||
--link-color---opacity-low: hsla(203.8775510204082, 80.32786885245902%, 52.156862745098046%, 0.25); | ||
--link-color---opacity-lower: hsla(203.8775510204082, 80.32786885245902%, 52.156862745098046%, 0.1); | ||
--link-color---opacity-med: hsla(203.8775510204082, 80.32786885245902%, 52.156862745098046%, 0.5); | ||
--link-color: #2399E7; | ||
--text-highlight-color---opacity-high: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.75); | ||
--text-highlight-color---opacity-higher: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.85); | ||
--text-highlight-color---opacity-low: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.25); | ||
--text-highlight-color---opacity-lower: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.1); | ||
--text-highlight-color---opacity-med: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.5); | ||
--text-highlight-color: #FBBE63; | ||
--warning-color---opacity-high: hsla(8.571428571428555, 74.11764705882354%, 50%, 0.75); | ||
--warning-color---opacity-higher: hsla(8.571428571428555, 74.11764705882354%, 50%, 0.85); | ||
--warning-color---opacity-low: hsla(8.571428571428555, 74.11764705882354%, 50%, 0.25); | ||
--warning-color---opacity-lower: hsla(8.571428571428555, 74.11764705882354%, 50%, 0.1); | ||
--warning-color---opacity-med: hsla(8.571428571428555, 74.11764705882354%, 50%, 0.5); | ||
--warning-color: #DE3C21; | ||
} | ||
|
||
.docs-story { | ||
background: var(--background-color); | ||
}` | ||
|
||
const StoryWrapper = styled.div` | ||
`; | ||
|
||
export const decorators = [ | ||
(Story) => ( | ||
<StoryWrapper> | ||
<style>{cssVars}</style> | ||
<Story /> | ||
</StoryWrapper> | ||
), | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# X. JS Components | ||
|
||
Date: 2021-08-23 | ||
|
||
## Status | ||
|
||
Proposed. | ||
|
||
|
||
## Context | ||
|
||
Inspired by [David Nolen's ClojureScript in the Age of TypeScript](https://vouch.io/developing-mobile-digital-key-applications-with-clojurescript/) talk and post, we started thinking about how viable it would be to use JS (instead of CLJS) components. | ||
|
||
This change would provide design with a better and more familiar development environment for components and reduce their dependency on engineering to ship work. | ||
The separation also has several second order benefits related to organization and communication. | ||
|
||
Costs for this change are centered around the degree of separation between application and components, where cljs is the primary language on the former and js on the latter, and maintaining extra tooling. | ||
|
||
|
||
## Decision | ||
|
||
TBD | ||
|
||
|
||
## Consequences | ||
|
||
Negative consequences: | ||
* JS/CLJS context switching when working in the app and on components at the same time | ||
* Higher surface area for JS interop problems | ||
* More complex build step | ||
* More tooling to maintain | ||
* Harder for for CLJS engineers to develop and maintain components | ||
|
||
|
||
Positive consequences: | ||
* Better development and testing environment for components | ||
* Clearer defined deliverable scope and context for components | ||
* Component documentation | ||
* Smaller and simpler application codebase | ||
* Looser coupling between engineering and design | ||
* Design can deliver work on separate cadence, units, and timeline, from engineering | ||
* Easier to enforce discipline on components as pure functions | ||
* CLJS proficiency is not necessary for design work | ||
* Easier for contributors to contribute to components | ||
* Reduced bus factor in design | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creating another pointer to our Hypotheses G Docs. ADRs capture the design of an architectural decision, some of the trade-offs, and some of the motivations, but could still be made more explicit in terms of the design of decision-making from an organizational point of view. Perhaps we should link to the doc here? Fine if only privately accessible for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
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.
What is the reason we compile components 3x?
Can't we cache the result of 1st complication and reuse in other 2 places?
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.
Roughly the same reason we compile the app in those 3 places too: the are being used as a build step prior to the app build step, so whenever the app gets built the components should be built as well.
It should be possible to cache the results of the compilation, especially since the component compilation is simpler than the app compilation. But caching brings its own set of problems, like determining the cache invalidation policy (yarn.lock+all ts files for now, maybe different later), and I can't imagine it will bring any benefit since compiling the components is faster than restoring cache+storing cache for now.
So I don't really see a reason to use cache at the moment.
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.
Do these components get served anywhere? Before, we could see devcards at contributor github pages at like
username.github.io/athens/cards.html
. This is a great way to see contributor/PR components without building locally.Our hypothetical
athensresearch.github.io/athens/storybook.html
, could also host the official components/design system.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.
They aren't served anywhere now, no. I think they can be built with
yarn build-storybook
in this fashion. Afterwards they would need to be deployed.For contributors to show them they'd also have to somehow deploy them to github pages though. How was that done before?
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.
Another note: athensresearch.github.io is essentially a singleton for the master branch deployment, we can't deploy there until rtc is merged into master.
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.
https://handbook.athensresearch.org/community/get-involved/setup#deploying-athens-and-devcards
That's a good point. Right now, Github pages are only updated when main is deployed via a tagged release.
In the past, I setup Actions so that contributors would update their GitHub pages whenever they pushed to any branch, not just when they pushed to their main. The problem here was that if they pushed to another branch, it would update. I even dynamically included their Git hash and linked to the GitHub commit in their GitHub pages Athens build. Actually, none of this worked out that well, and the easiest ended up being that I just added their fork as a remote and built it locally every time I was reviewing their PR. This should probably still be the workflow going forward for PR reviews.
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.
I think we want a way to preview these changes via temporary deployment but not too sure how to do it now without involving some third party service.
Probably could deploy to GH pages under a branch name path. Then clean up that on merge? GH actions has a rich enough API to do that. Probably needs an ADR of it's own.
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.
The problem with GH pages is it would only be able to serve one branch at a time. I feel like a service like Vercel could have a deploy for an arbitrary number of git hashes. This is too much overhead for most contributors, but I could seem it being more valuable when we have several people iterating on frontend code consistently.
For now, I think it's fine for all engineers to have remotes for one another. Building locally is another step of reproducibilty which can actually be helpful. Finally, modifying and hot-reloading code is something that a service deploy wouldn't allow for. Interacting with the code and application is gold for understanding it!
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.
WRT #1564 (comment), talked to Alex on standup and he prefer the faster build than the caching for now.