Skip to content

Commit

Permalink
Revert "Merge pull request athensresearch#2344 from filipesilva/react…
Browse files Browse the repository at this point in the history
…-18"

This reverts commit 3833579, reversing
changes made to 4eb6b5e.
  • Loading branch information
tangjeff0 committed Sep 7, 2022
1 parent be23702 commit a53ff7d
Show file tree
Hide file tree
Showing 15 changed files with 7,125 additions and 966 deletions.
37 changes: 37 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

module.exports = {
features: {
postcss: false,
},
"stories": [
"../src/js/**/*.stories.mdx",
"../src/js/**/*.stories.tsx"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-a11y",
'storybook-dark-mode',
'@geometricpanda/storybook-addon-badges'
],
webpackFinal: async (config, { configType }) => {
// Resolve the root path defined in tsconfig.json
config.resolve.plugins.push(
new TsconfigPathsPlugin({
configFile: path.resolve(__dirname, '../tsconfig.json'),
})
);

// Support mjs modules included with Chakra-UI
// https://github.com/storybookjs/storybook/issues/16690#issuecomment-971579785
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto",
})
// Return the altered config.
return config;
}
}
74 changes: 74 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from 'react';

import { themes } from '@storybook/theming';
import { ChakraProvider } from '@chakra-ui/react';


import { theme } from '../src/js/theme/theme';
import { badges, Storybook } from '../src/js/components/utils/storybook';

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
layout: 'fullscreen',
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
badgesConfig: {
...badges
},
darkMode: {
// Override the default dark theme
dark: {
...themes.dark,
appBg: '#151515',
appContentBg: '#1A1A1A',
},
// Override the default light theme
light: {
...themes.normal,
appBg: '#EFEDEB',
appContentBg: "#F6F6F6"
}
}
}

export const globalTypes = {
theme: {
name: 'Story Theme',
description: 'Global theme for components',
defaultValue: 'light',
toolbar: {
// Array of plain string values or MenuItem shape (see below)
items: ['light', 'dark'],
// Property that specifies if the name of the item will be displayed
showName: true,
},
},
};


export const decorators = [
(Story, context) => {

React.useEffect(() => {
const theme = context.globals.theme === 'dark' ? 'is-theme-dark' : 'is-theme-light';
document.body.classList.add(theme);
return () => document.body.classList.remove(theme);
}, [context])

console.log(context);
return (
<>
<ChakraProvider>
<Storybook.App
id="app" >
<Story />
</Storybook.App>
</ChakraProvider>
</>
)
},
];
10 changes: 8 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ module.exports = {
preventFullImport: true
}
}],
["@babel/proposal-class-properties"],
["@babel/proposal-object-rest-spread"],
// Our build doesn't need the {loose: true} option, but if not included it wil
// show a lot of warnings on the storybook build.
["@babel/proposal-class-properties", {loose: true}],
["@babel/proposal-object-rest-spread", {loose: true}],
// Used only by storybook, but must be included to avoid build warnings/errors.
["@babel/plugin-proposal-private-methods", {loose: true}],
["@babel/plugin-proposal-private-property-in-object", {loose: true}],
// Import helpers from @babel/runtime instead of duplicating them everywhere.
"@babel/plugin-transform-runtime",
// Better debug information for styled components.
Expand All @@ -70,5 +75,6 @@ module.exports = {
// Do not apply this babel config to node_modules.
// Shadow-CLJS also runs babel over node_modules and we don't want this
// configuration to apply to it.
// We still want it to be picked up by storybook though.
exclude: ["node_modules"]
}
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
cljc.java-time/cljc.java-time #:mvn{:version "0.1.9"}
com.rpl/specter #:mvn{:version "1.1.3"}
com.taoensso/sente #:mvn{:version "1.16.2"}
binaryage/devtools #:mvn{:version "1.0.6"}
binaryage/devtools #:mvn{:version "1.0.3"}
day8.re-frame/re-frame-10x #:mvn{:version "1.5.0"}
day8.re-frame/tracing #:mvn{:version "0.6.2"}
org.flatland/ordered #:mvn{:version "1.15.10"}
Expand Down
37 changes: 0 additions & 37 deletions fix-node-modules-class-fields.js

This file was deleted.

19 changes: 14 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
"scripts": {
"// repo scripts": "",
"postinstall": "node fix-node-modules-class-fields.js",
"update:dry": "standard-version --dry-run -p --releaseCommitMessageFormat v{{currentTag}}",
"update": "standard-version -p --releaseCommitMessageFormat v{{currentTag}}",
"clean": "rimraf resources/public/**/*.js resources/public/**/*.js.map target .shadow-cljs src/gen",
Expand All @@ -22,7 +21,7 @@
"notebooks": "clojure -M:notebooks",
"notebooks:static": "clojure -X:notebooks-static",
"vercel:install": "./script/vercel-setup.sh && yarn && clojure -P",
"vercel:build": "yarn notebooks:static && yarn client:web:static",
"vercel:build": "yarn notebooks:static && yarn storybook:static && yarn client:web:static",
"// client scripts": "",
"dev": "yarn components && concurrently \"yarn components:watch\" \"yarn client:watch\"",
"client:watch": "shadow-cljs watch main renderer app",
Expand All @@ -34,6 +33,8 @@
"components:watch": "yarn components --watch",
"prod": "yarn components && shadow-cljs release main renderer app",
"dist": "electron-builder -p always",
"storybook": "start-storybook -p 6006",
"storybook:static": "build-storybook --output-dir vercel-static/storybook --quiet",
"// client e2e scripts": "",
"// add --config=playwright.electron.config.ts to any e2e script to use electron instead of web build": "",
"client:e2e": "xvfb-maybe playwright test",
Expand Down Expand Up @@ -100,11 +101,12 @@
},
"dependencies": {
"@babel/runtime": "^7.15.4",
"@chakra-ui/react": "^2.2.9",
"@chakra-ui/react": "^1.8.6",
"@dnd-kit/core": "^6.0.5",
"@dnd-kit/sortable": "^7.0.1",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@geometricpanda/storybook-addon-badges": "^0.0.4",
"@js-joda/core": "1.12.0",
"@js-joda/locale_en-us": "3.1.1",
"@js-joda/timezone": "2.2.0",
Expand All @@ -123,11 +125,11 @@
"luxon": "^2.0.2",
"nedb": "^1.8.0",
"polished": "^4.1.3",
"react": "18.2.0",
"react": "17.0.1",
"react-codemirror2": "^7.2.1",
"react-colorful": "^5.4.0",
"react-day-picker": "^7.4.10",
"react-dom": "18.2.0",
"react-dom": "17.0.1",
"react-error-boundary": "^3.1.4",
"react-force-graph-2d": "^1.19.0",
"react-highlight.js": "1.0.7",
Expand All @@ -148,6 +150,11 @@
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@playwright/test": "^1.17.1",
"@storybook/addon-a11y": "^6.3.8",
"@storybook/addon-actions": "^6.3.8",
"@storybook/addon-essentials": "^6.3.8",
"@storybook/addon-links": "^6.3.8",
"@storybook/react": "^6.3.8",
"babel-loader": "^8.2.2",
"babel-plugin-module-resolver": "^4.1.0",
"babel-plugin-styled-components": "^1.13.2",
Expand All @@ -167,6 +174,8 @@
"shadow-cljs": "2.19.5",
"source-map-support": "^0.5.19",
"standard-version": "^9.3.1",
"storybook-dark-mode": "^1.0.8",
"tsconfig-paths-webpack-plugin": "^3.5.1",
"typescript": "^4.3.5",
"vercel": "^24.2.3",
"xvfb-maybe": "^0.2.1"
Expand Down
6 changes: 2 additions & 4 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
:compiler-options {:closure-warnings {:global-this :off}
:infer-externs :auto
:closure-defines {re-frame.trace.trace-enabled? true}
:output-feature-set :es-next
:external-config {:devtools/config {:features-to-install [:formatters :hints]}}}
:output-feature-set :es-next}
:dev {:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true
day8.re-frame.tracing.trace-enabled? true}
;; Hide redef warnings, we started having around 5 that show up
;; on every rebuild due to clojure 1.11 adding new fns.
:warnings {:redef false}}}
:release {:build-options {:ns-aliases {day8.re-frame.tracing day8.re-frame.tracing-stubs}}}
:devtools {:preloads [devtools.preload
#_day8.re-frame-10x.preload]
day8.re-frame-10x.preload]
:http-root "resources/public"
:http-port 3000}}

Expand All @@ -40,7 +39,6 @@
:infer-externs :auto
:closure-defines {re-frame.trace.trace-enabled? true}
:output-feature-set :es-next
:external-config {:devtools/config {:features-to-install [:formatters :hints]}}
;; see https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading
:reader-features #{:electron}}
:dev {:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true
Expand Down
9 changes: 3 additions & 6 deletions src/cljs/athens/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
["@sentry/integrations" :as integrations]
["@sentry/react" :as Sentry]
["@sentry/tracing" :as tracing]
["react-dom/client" :refer [createRoot]]
[athens.coeffects]
[athens.common.logging :as log]
[athens.components]
Expand All @@ -23,7 +22,7 @@
[datalog-console.integrations.datascript :as datalog-console]
[goog.dom :refer [getElement]]
[re-frame.core :as rf]
[reagent.core :as r]))
[reagent.dom :as r-dom]))


(goog-define SENTRY_DSN "")
Expand All @@ -35,15 +34,13 @@
(log/info "dev mode")))


(defonce react-root (createRoot (getElement "app")))


(defn ^:dev/after-load mount-root
[first-boot?]
(rf/clear-subscription-cache!)
(when-not first-boot?
(router/init-routes!))
(.render react-root (r/as-element [views/main])))
(r-dom/render [views/main]
(getElement "app")))


(defn sentry-on?
Expand Down
6 changes: 3 additions & 3 deletions src/cljs/athens/util.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,21 @@
[]
(when config/debug?
(let [el-10x (getElement "--re-frame-10x--")
display-10x (and el-10x (.. el-10x -style -display))]
display-10x (.. el-10x -style -display)]
(not (= "none" display-10x)))))


(defn open-10x
[]
(when config/debug?
(when-let [el (js/document.querySelector "#--re-frame-10x--")]
(let [el (js/document.querySelector "#--re-frame-10x--")]
(setProperties el (clj->js {"style" "display: block"})))))


(defn hide-10x
[]
(when config/debug?
(when-let [el (js/document.querySelector "#--re-frame-10x--")]
(let [el (js/document.querySelector "#--re-frame-10x--")]
(setProperties el (clj->js {"style" "display: none"})))))


Expand Down
Loading

0 comments on commit a53ff7d

Please sign in to comment.