Skip to content

Commit

Permalink
Merge pull request #908 from ChainSafe/dev
Browse files Browse the repository at this point in the history
Crash when going back after having selected Google auth #860 (PR #871)
Login optimizations (PR #879)
Minor fixes + Updates to color manipulator (#874)
Merge pull request #879 from ChainSafe/fix/login-optimizations
Merge pull request #887 from ChainSafe/fix/tbaut-hover-color
Merge pull request #886 from ChainSafe/feat/tkey-darkmode
Remove code duplication (#889)
Merge pull request #895 from ChainSafe/fix/select-all-892
Merge pull request #896 from ChainSafe/fix/mouse-highlight-issue-890
Merge pull request #894 from ChainSafe/fix/mobile-spinner-893
Merge pull request #877 from ChainSafe/feat/tbaut-settings-security-846
folder validation (#899)
saved browsers settings (#865)
Prevent the whole app from rerendering every 5s (#909)
Merge pull request #911 from ChainSafe/fix/share-transfer-modal-on-ta… …
Merge pull request #905 from ChainSafe/fix/bin-file-view-873 …
Merge pull request #906 from ChainSafe/feat/home-folder-nav-885 …
Merge pull request #907 from ChainSafe/fix/search-bucket-to-reset-on-…
Fix: Search results all show as files (#914) …
Fix double click opening the next file preview (#915) …
Rename tooltip and fixes (#912) …
  • Loading branch information
FSM1 authored Apr 12, 2021
2 parents d633abe + ef4366d commit 0392f31
Show file tree
Hide file tree
Showing 50 changed files with 2,145 additions and 1,046 deletions.
1 change: 1 addition & 0 deletions packages/common-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"devDependencies": {
"@babel/core": "^7.12.10",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-image": "^2.0.6",
"@rollup/plugin-node-resolve": "^10.0.0",
"@storybook/addon-actions": "^5.3.21",
"@storybook/addon-contexts": "^5.3.19",
Expand Down
14 changes: 8 additions & 6 deletions packages/common-components/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import svgr from "@svgr/rollup"
import url from "rollup-plugin-url"
import babel from "rollup-plugin-babel"
import postcss from "rollup-plugin-postcss"
import image from "@rollup/plugin-image"

export default {
input: "./src/index.ts",
Expand All @@ -14,30 +15,31 @@ export default {
dir: "dist/",
exports: "named",
sourcemap: true,
strict: true,
strict: true
},
plugins: [
image(),
peerDepsExternal(),
resolve(),
commonjs(),
typescript(),
postcss({
plugins: [],
plugins: []
}),
url(),
svgr(),
babel({
exclude: "node_modules/**",
presets: ["@babel/preset-react", "@babel/preset-env"],
plugins: ["emotion"],
}),
plugins: ["emotion"]
})
],
external: [
"react",
"react-dom",
"@material-ui/styles",
"formik",
"react-toast-notifications",
"@chainsafe/common-theme",
],
"@chainsafe/common-theme"
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react"
import { makeStyles, createStyles, ITheme } from "@chainsafe/common-theme"
import clsx from "clsx"
import ChainSafePng from "./logo.png"

const useStyles = makeStyles(({ overrides }: ITheme) =>
createStyles({
Expand All @@ -17,7 +18,7 @@ const ChainsafeFilesLogo: React.FC<{ className?: string }> = ({
const classes = useStyles()
return (
<img
src="ChainSafe-logo.png"
src={ChainSafePng}
alt="Chainsafe Logo"
className={clsx(classes.root, className)}
/>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 40 additions & 19 deletions packages/common-components/src/ExpansionPanel/ExpansionPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode, useState } from "react"
import React, { ReactNode, useCallback, useState } from "react"
import { ITheme, makeStyles, createStyles } from "@chainsafe/common-theme"
import { Typography } from "../Typography"
import clsx from "clsx"
Expand Down Expand Up @@ -35,6 +35,7 @@ const useStyles = makeStyles(
}px`,
color: palette.additional["gray"][9],
cursor: "pointer",
display: "flex",
"&.basic": {
backgroundColor: palette.additional["gray"][2],
...overrides?.ExpansionPanel?.heading?.basic?.root,
Expand All @@ -56,6 +57,9 @@ const useStyles = makeStyles(
},
...overrides?.ExpansionPanel?.heading?.root
},
flexGrow: {
flex: 1
},
content: {
overflow: "hidden",
color: palette.additional["gray"][8],
Expand Down Expand Up @@ -90,37 +94,54 @@ export interface IExpansionPanelProps {
children?: ReactNode | ReactNode[] | null
active?: boolean
variant?: "basic" | "borderless"
iconPosition?: "left" | "right"
toggle?: (state: boolean) => void
injectedClasses?: {
root?: string
heading?: string
content?: string
}
}

const ExpansionPanel: React.FC<IExpansionPanelProps> = ({
children,
header,
variant = "basic",
toggle,
active
}: IExpansionPanelProps) => {
const ExpansionPanel = ({ children, header, iconPosition, variant = "basic", toggle, active, injectedClasses }: IExpansionPanelProps) => {
const classes = useStyles()
const [activeInternal, setActive] = useState(!!active)
const handleToggle = () => {
const handleToggle = useCallback(() => {
toggle && toggle(!activeInternal)
setActive(!activeInternal)
}
}, [activeInternal, toggle])

return (
<div className={clsx(classes.root, variant)}>
<div className={clsx(classes.root, variant, injectedClasses?.root)}>
<section
onClick={() => handleToggle()}
className={clsx(classes.heading, variant, {
["active"]: active != undefined ? active : activeInternal
})}
onClick={handleToggle}
className={clsx(
classes.heading,
variant,
injectedClasses?.heading,
{
["active"]: active !== undefined ? active : activeInternal
}
)}
>
<DirectionalRightIcon className={classes.icon} />
{iconPosition === "left" && <DirectionalRightIcon className={classes.icon} />}
<Typography>{header}</Typography>
{iconPosition === "right" && (
<>
<div className={classes.flexGrow} />
<DirectionalRightIcon className={classes.icon} />
</>
)}
</section>
<section
className={clsx(classes.content, variant, {
["active"]: active != undefined ? active : activeInternal
})}
className={clsx(
classes.content,
variant,
injectedClasses?.content,
{
["active"]: active !== undefined ? active : activeInternal
}
)}
>
{children}
</section>
Expand Down
7 changes: 1 addition & 6 deletions packages/common-components/src/TextInput/FormikTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ const FormikTextInput = React.forwardRef(
name={field.name}
value={field.value}
placeholder={placeholder}
captionMessage={
<>
{captionMessage && captionMessage}
{meta.touched && meta.error && `${meta.error}`}
</>
}
captionMessage={meta.error ? `${meta.error}` : captionMessage ? captionMessage : null}
state={meta.error ? "error" : undefined}
onChange={helpers.setValue}
autoFocus={autoFocus}
Expand Down
14 changes: 5 additions & 9 deletions packages/common-components/src/Toaster/ToasterWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import React from "react"
import React, { useCallback } from "react"
import ToasterContent from "./ToasterContent"
import {
useToasts,
AppearanceTypes,
Placement
} from "react-toast-notifications"
import { useToasts, AppearanceTypes, Placement } from "react-toast-notifications"

export interface IToasterMessage {
message: string
description?: string
appearance?: AppearanceTypes
autoDismiss?: boolean
onDismiss?(id: string): void
onDismiss?: (id: string) => void
}

export const useToaster = () => {
const { addToast } = useToasts()

const addToastMessage = (config: IToasterMessage) => {
const addToastMessage = useCallback((config: IToasterMessage) => {
addToast(
<ToasterContent
message={config.message}
Expand All @@ -29,7 +25,7 @@ export const useToaster = () => {
onDismiss: config.onDismiss
}
)
}
}, [addToast])

return {
addToastMessage
Expand Down
51 changes: 27 additions & 24 deletions packages/common-components/src/stories/Breadcrumb.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react"
import React, { useMemo } from "react"
import { action } from "@storybook/addon-actions"
import { boolean, withKnobs, text } from "@storybook/addon-knobs"
import { Breadcrumb } from "../Breadcrumb"
Expand All @@ -15,26 +15,29 @@ export const actionsData = {
homeClicked: action("Clicked link")
}

export const BreadcrumbStory = (): React.ReactNode => (
<>
<Breadcrumb
homeOnClick={() => actionsData.homeClicked()}
showDropDown={boolean("show dropdown", true)}
crumbs={[
{
text: text("breadcrumb 2", "Level 1 Clickable"),
onClick: () => actionsData.linkClick()
},
{
text: "Level 2"
},
{
text: "Level 3"
},
{
text: "Level 4"
}
]}
/>
</>
)
export const BreadcrumbStory = (): React.ReactNode => {
const crumbs = useMemo(() => ([
{
text: text("breadcrumb 2", "Level 1 Clickable"),
onClick: () => actionsData.linkClick()
},
{
text: "Level 2"
},
{
text: "Level 3"
},
{
text: "Level 4"
}
]), [])

return (
<>
<Breadcrumb
homeOnClick={() => actionsData.homeClicked()}
showDropDown={boolean("show dropdown", true)}
crumbs={crumbs}
/>
</>
)}
1 change: 1 addition & 0 deletions packages/common-components/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "*.png"
1 change: 1 addition & 0 deletions packages/common-themes/src/Defaults/GlobalStyling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DefaultThemeConfig, defaultFontFamilyStack } from "./ThemeConfig"

export const DefaultGlobalStyling = {
":root": {
"--ready": "true",
...DefaultPalette.root
},
html: {
Expand Down
4 changes: 2 additions & 2 deletions packages/common-themes/src/Defaults/ThemeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ const DefaultThemeConfig: IThemeConfig = {
blocker: 10000
},
shadows: {
shadow1: `0px 1px 4px ${fade(DefaultPalette.additional.gray[10], 0.15)}`,
shadow2: `0px 2px 8px ${fade(DefaultPalette.additional.gray[10], 0.25)}`
shadow1: `0px 1px 4px ${fade("#000000", 0.15)}`, // Gray[10] // TODO: #875
shadow2: `0px 2px 8px ${fade("#000000", 0.25)}` // Gray[10] // TODO: #875
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/common-themes/src/Hooks/useDoubleClick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function useDoubleClick(actionSingleClick: () => void, actionDoubleClick:
// the duration between this click and the previous one
// is less than the value of delay = double-click
if (clickCount === 2) {
setClickCount(0)
actionDoubleClick && actionDoubleClick()
}

Expand Down
22 changes: 19 additions & 3 deletions packages/common-themes/src/utils/colorManipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,38 @@ export function decomposeColor(color: string): IColorObject {

if (["rgb", "rgba", "hsl", "hsla", "var"].indexOf(type) === -1) {
throw new Error(
"Material-UI: Unsupported `%s` color.\n" +
`ChainSafe themes: Unsupported ${type} color.\n` +
"We support the following formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), var()."
)
}

let colorToParse = `${color}`

if (type === "var") {
colorToParse = getComputedStyle(document.documentElement).getPropertyValue(color.substr(marker + 1, color.length - 1))
// Check if loaded
if (!getComputedStyle(document.documentElement).getPropertyValue("--ready")) {
// throw new Error(
// "Css variable not loaded yet"
// )
// TODO: #875: Resolve variables not being loaded in time issue
console.debug("Css variable not loaded yet")
}

colorToParse = getComputedStyle(document.documentElement).getPropertyValue(color.replace("var(", "").replace(")", ""))
if (colorToParse.charAt(0) === "#") {
return decomposeColor(
hexToRgb(
colorToParse
)
)
}
}

const valuesStrings = colorToParse
.substring(marker + 1, colorToParse.length - 1)
.split(",")
const values = valuesStrings.map((value) => parseFloat(value))

const values = valuesStrings.map((value) => parseFloat(value))
return { type: type as ColorFormat, values: values as ColorValues }
}

Expand Down
Loading

0 comments on commit 0392f31

Please sign in to comment.