Skip to content
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

Merged
merged 22 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
59c6629
build: support tsx components and storybook
filipesilva Aug 19, 2021
6689ad5
improvement(storybook): props and style for button test case
shanberg Aug 21, 2021
c5ec43e
improvement(storybook): improve file structure
shanberg Aug 22, 2021
107d3dd
feat: build proper tsx button component
shanberg Aug 22, 2021
c9e2ff5
rfct: use new button component
shanberg Aug 22, 2021
1e83f82
Merge pull request #1 from shanberg/add-component-story
filipesilva Aug 23, 2021
a514a01
rfct: remove compiled files
filipesilva Aug 23, 2021
1396e81
build: don't compile stories to js
filipesilva Aug 23, 2021
ce3d3bd
rfct: style
filipesilva Aug 23, 2021
17e6570
rfct: use dash-case for button props
filipesilva Aug 23, 2021
f87e920
docs: add js components ADR
filipesilva Aug 23, 2021
b4eb289
rfct: remove unused files
filipesilva Aug 31, 2021
432ba63
rfct: simplify yarn clean cmd
filipesilva Aug 31, 2021
6b84ae2
rfct: rename storybook scripts for consistency
filipesilva Aug 31, 2021
7886600
fix: remove unused src path
filipesilva Aug 31, 2021
a23223e
build: only watch component dir for components
filipesilva Aug 31, 2021
79397e2
docs: update js components ADR
filipesilva Sep 2, 2021
3cfe181
Merge branch 'feature/rtc-v1' into storybook
filipesilva Sep 2, 2021
492f591
rfct: remove devcards
filipesilva Sep 2, 2021
2a50714
rfct: remove main devcards file
filipesilva Sep 8, 2021
fdce6c0
build: ignore storybook build folder
filipesilva Sep 8, 2021
8c668d2
docs: add deferred work items to JS components ADR
filipesilva Sep 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
- name: Fetch JS deps
run: yarn

- name: Compile components
run: yarn components

# TODO: re-enable once web build is fixed
# - name: Run Karma tests
# run: script/test/karma
Expand Down Expand Up @@ -164,6 +167,9 @@ jobs:
- name: Fetch yarn
run: yarn install --frozen-lockfile

- name: Compile components
run: yarn components

- name: Compile app
run: COMMIT_URL="https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}" lein run -m shadow.cljs.devtools.cli --npm release app --config-merge "{:closure-defines {athens.core/SENTRY_DSN \"${SENTRY_DSN}\" athens.util/COMMIT_URL \"${COMMIT_URL}\" }}"
env:
Expand Down Expand Up @@ -238,6 +244,9 @@ jobs:
mkdir -p ~/private_keys/
echo '${{ secrets.api_key }}' > ~/private_keys/AuthKey_${{ secrets.api_key_id }}.p8

- name: Compile components
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For contributors to show them they'd also have to somehow deploy them to github pages though. How was that done before?

https://handbook.athensresearch.org/community/get-involved/setup#deploying-athens-and-devcards

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.

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

@tangjeff0 tangjeff0 Sep 3, 2021

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!

Copy link
Collaborator Author

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.

run: yarn components

- name: Compile JS Assets (*nix)
if: matrix.os != 'windows-latest'
run: lein run -m shadow.cljs.devtools.cli --npm release main renderer --config-merge "{:closure-defines {athens.core/SENTRY_DSN \"${SENTRY_DSN}\"}}"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@

# electron build
dist

# design system ts output
/src/js/components/**/*.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, I my git is recognizing unstaged changes in /src/js/components/Button/Button.js and /src/js/components/Button/Button.stories.js. The diff is just different slightly differenent transpiled TS=>JS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.25.1. Can look into it and add my repro steps.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine now. But storybook-static/ code is being created. Do we want all these files?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignored

19 changes: 19 additions & 0 deletions .storybook/main.js
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;
}
}
146 changes: 146 additions & 0 deletions .storybook/preview.js
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 = `
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with Stuart how this is duplication of code in athens.style, and how we could put it in a JS file and use it as the source of truth for both setups. Left it as is for now to reduce scope of the PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want athens.style to be CSS/JS in the future? Might be better for OSS devs and theme developers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah just the part that is all the CSS properties.

Copy link
Collaborator

@shanberg shanberg Sep 4, 2021

Choose a reason for hiding this comment

The 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>
),
];
30 changes: 23 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@
"scripts": {
"update:dry": "standard-version --dry-run -p --releaseCommitMessageFormat v{{currentTag}}",
"update": "standard-version -p --releaseCommitMessageFormat v{{currentTag}}",
"dev": "shadow-cljs watch main renderer app",
"compile": "shadow-cljs compile main renderer app",
"prod": "shadow-cljs release main renderer app",
"clean": "rm -rf resources/public/**/*.js && rm -rf target && rm -rf .shadow-cljs",
"dist": "electron-builder -p always"
"dev": "concurrently \"yarn components:watch\" \"yarn client:watch\"",
"client:watch": "shadow-cljs watch main renderer app",
"components": "yarn tsc",
"components:watch": "yarn tsc --watch",
"compile": "yarn components && shadow-cljs compile main renderer app",
"prod": "yarn components && shadow-cljs release main renderer app",
"clean": "rm -rf resources/public/**/*.js && rm -rf target && rm -rf .shadow-cljs && rm -rf ./src/stories/**/*.js",
filipesilva marked this conversation as resolved.
Show resolved Hide resolved
"dist": "electron-builder -p always",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
filipesilva marked this conversation as resolved.
Show resolved Hide resolved
},
"main": "resources/main.js",
"build": {
Expand Down Expand Up @@ -66,16 +71,26 @@
"electron-log": "^4.2.4",
"electron-updater": "^4.3.4",
"highlight.js": "^10.7.2",
"iconoir": "^1.0.0",
"katex": "^0.12.0",
"marked": "^1.0.0",
"nedb": "^1.8.0",
"react": "17.0.1",
"react-codemirror2": "^7.2.1",
"react-dom": "17.0.1",
"react-force-graph-2d": "^1.19.0",
"react-highlight.js": "1.0.7"
"react-highlight.js": "1.0.7",
"styled-components": "^5.3.0",
"tslib": "^2.3.1"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@storybook/addon-actions": "^6.3.7",
"@storybook/addon-essentials": "^6.3.7",
"@storybook/addon-links": "^6.3.7",
"@storybook/react": "^6.3.7",
"babel-loader": "^8.2.2",
"concurrently": "^6.2.1",
"electron": "^12.0.4",
"electron-builder": "22.10",
"electron-builder-notarize": "^1.2.0",
Expand All @@ -86,7 +101,8 @@
"karma-junit-reporter": "^2.0.1",
"shadow-cljs": "^2.15.3",
"source-map-support": "^0.5.19",
"standard-version": "^9.3.1"
"standard-version": "^9.3.1",
"typescript": "^4.3.5"
},
"standard-version": {
"types": [
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

:min-lein-version "2.5.3"

:source-paths ["src/clj" "src/cljs" "src/cljc" "src/js"]
:source-paths ["src/clj" "src/cljs" "src/cljc" "src/js" "src/stories"]
filipesilva marked this conversation as resolved.
Show resolved Hide resolved

:main athens.self-hosted.core
:aot [athens.self-hosted.core]
Expand Down
4 changes: 2 additions & 2 deletions src/cljs/athens/devcards/all_pages.cljs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(ns athens.devcards.all-pages
(:require
["/components/Button/Button" :refer [Button]]
[athens.db :as db]
[athens.devcards.db :refer [load-real-db-button]]
[athens.views.buttons :refer [button]]
[athens.views.pages.all-pages :as all-pages]
[datascript.core :as d]
[devcards.core :refer [defcard defcard-rg]]
Expand All @@ -19,7 +19,7 @@

(defcard-rg Create-Page
"Page title increments by more than one each time because we create multiple entities (the child blocks)."
[button {:on-click (fn []
[:> Button {:on-click (fn []
(let [n (:max-eid @db/dsdb)]
(d/transact! db/dsdb [{:node/title (str "Test Title " n)
:block/uid (str "uid" n)
Expand Down
4 changes: 2 additions & 2 deletions src/cljs/athens/devcards/athena.cljs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
(ns athens.devcards.athena
(:require
["/components/Button/Button" :refer [Button]]
[athens.db :as db]
[athens.devcards.db :refer [load-real-db-button]]
[athens.subs]
[athens.views.athena :refer [athena-prompt-el athena-component]]
[athens.views.buttons :refer [button]]
[datascript.core :as d]
[devcards.core :refer-macros [defcard-rg]]))


(defcard-rg Create-Page
"Press button and then search \"test\" "
[button {:on-click (fn []
[:> Button {:on-click (fn []
(let [n (inc (:max-eid @db/dsdb))
n-child (inc n)]
(d/transact! db/dsdb [{:node/title (str "Test Page " n)
Expand Down
6 changes: 3 additions & 3 deletions src/cljs/athens/devcards/db.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns athens.devcards.db
(:require
[athens.db :as db]
[athens.views.buttons :refer [button]]
["/components/Button/Button" :refer [Button]]
[cljs-http.client :as http]
[cljs.core.async :refer [go <!]]
[cljsjs.react]
Expand Down Expand Up @@ -32,14 +32,14 @@
(swap! pressed? not)
(load-real-db!))]
(fn []
[button {:disabled @pressed?
[:> Button {:disabled @pressed?
:on-click handler} "Load Real Data"])))


(defn reset-db-button
[]
(fn []
[button {:on-click #(d/reset-conn! db/dsdb (d/empty-db db/schema))} "Reset DB"]))
[:> Button {:on-click #(d/reset-conn! db/dsdb (d/empty-db db/schema))} "Reset DB"]))


;; Devcards
Expand Down
6 changes: 3 additions & 3 deletions src/cljs/athens/devcards/devtool.cljs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(ns athens.devcards.devtool
(:require
["/components/Button/Button" :refer [Button]]
[athens.db :as db :refer [dsdb]]
[athens.devcards.db :refer [load-real-db-button]]
[athens.views.buttons :refer [button]]
[athens.views.devtool :refer [state* handler devtool-prompt-el
devtool-component initial-state eval-box!]]
[datascript.db]
Expand All @@ -18,12 +18,12 @@

(defcard-rg Create-Page
"Press button and then search \"test\" "
[button {:on-click handler} "Create Test Pages and Blocks"])
[:> Button {:on-click handler} "Create Test Pages and Blocks"])


(defcard-rg Reset-to-all-pages
(fn []
[button {:on-click #(do (swap! state* assoc :eval-str (:eval-str initial-state))
[:> Button {:on-click #(do (swap! state* assoc :eval-str (:eval-str initial-state))
(eval-box!))}
"Reset"]))

Expand Down
4 changes: 2 additions & 2 deletions src/cljs/athens/devcards/left_sidebar.cljs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(ns athens.devcards.left-sidebar
(:require
[athens.db :as db]
[athens.views.buttons :refer [button]]
["/components/Button/Button" :refer [Button]]
[athens.views.left-sidebar :refer [left-sidebar]]
[devcards.core :refer [defcard-rg]]
[posh.reagent :refer [transact!]]))


(defcard-rg Create-Shortcut
[button {:on-click (fn []
[:> Button {:on-click (fn []
(let [n (:max-eid @db/dsdb)]
(transact! db/dsdb [{:page/sidebar n
:node/title (str "Page " n)
Expand Down
4 changes: 2 additions & 2 deletions src/cljs/athens/devcards/right_sidebar.cljs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
(ns athens.devcards.right-sidebar
(:require
[athens.views.buttons :refer [button]]
["/components/Button/Button" :refer [Button]]
[athens.views.right-sidebar :as right-sidebar]
[devcards.core :refer [defcard-rg]]
[re-frame.core :refer [dispatch]]))


(defcard-rg Toggle
[button {:primary true :on-click-fn #(dispatch [:right-sidebar/toggle])} "Toggle"])
[:> Button {:isPrimary true :on-click-fn #(dispatch [:right-sidebar/toggle])} "Toggle"])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reagent will convert props in dash-chase into camelCase. So we can still keep using idiomatic property names in cljs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using :> everywhere, we can also declare these components with reagent/adapt-react-class somewhere. Not sure if it's worth the effort though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer dash-case.

I prefer :>.



(defcard-rg Right-Sidebar
Expand Down
Loading