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

Feat/migrate modals #401

Merged
merged 26 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e5bc181
Upgrade vite v4.2.1 -> v4.3.6
ehsan-github May 16, 2023
9d86f9a
Upgrade TypeScript v4 -> v5
ehsan-github May 16, 2023
ad4be23
Package upgrade
ehsan-github May 16, 2023
9c87416
Add .vscode configs
ehsan-github May 16, 2023
ebe5f3f
Fix type
ehsan-github May 16, 2023
bc2d758
Migrate Popup, Drawer, TinyPopup stories
ehsan-github May 16, 2023
f6ae7c8
Migrate Popup and TinyPopup to Chakra Modals
ehsan-github May 18, 2023
822ddbb
Migrate TinyPopup
ehsan-github May 19, 2023
207bd63
Customize chakra Drawer
ehsan-github May 21, 2023
a8e0fb6
Add bg on footer button focus
ehsan-github May 21, 2023
75f1819
Fix double focusable element for single entity
ehsan-github May 21, 2023
002ed11
Fix dark mode Notification
ehsan-github May 21, 2023
3ca67fd
Migrate Drawer to use Chakra Drawer
ehsan-github May 21, 2023
4137487
Add focus style to buttons
ehsan-github May 21, 2023
00b84d4
Remove unsuported comments on json
ehsan-github May 22, 2023
e21e521
Ok to run test on every push
ehsan-github May 22, 2023
f1aa3a2
Update Type
ehsan-github May 22, 2023
a386926
Reacher stories
ehsan-github May 22, 2023
7f688c0
Fix default value on storybook for trapFocus
ehsan-github May 22, 2023
8346e59
Fix Dropdown button height
ehsan-github May 22, 2023
91614a8
fix default blockScroll
ehsan-github May 22, 2023
d665fdd
Improve accessibility
ehsan-github May 23, 2023
eebf9b3
Add box-shadow when focusing on link buttons
ehsan-github May 23, 2023
5d44403
typo
ehsan-github May 23, 2023
0d4bdf6
format css
ehsan-github May 23, 2023
6432c11
chore
ehsan-github May 23, 2023
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
10 changes: 3 additions & 7 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: 'UI Tests'

on:
pull_request_review:
types: [submitted]
pull_request:
types: [review_requested]
on: pull_request

jobs:
# Run interaction and accessibility tests
Expand Down Expand Up @@ -32,12 +28,12 @@ jobs:

- name: Install chromium
run: yarn playwright install chromium

- name: Playwright component test
run: yarn test-ct
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
retention-days: 30
5 changes: 3 additions & 2 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
stories: [
'../src/**/*/stories.@(ts|tsx)',
Expand All @@ -15,6 +14,8 @@ const config: StorybookConfig = {
name: '@storybook/react-vite',
options: {},
},
docs: {
autodocs: true,
},
};

export default config;
83 changes: 43 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
"scripts": {
"build": "vite build",
"start": "vite build --watch",
"prepare": "run-s build",
"prepack": "run-s build",
"gen:cahkra-theme-typings": "chakra-cli tokens src/theme-chakra/theme/index.ts",
Copy link
Contributor

Choose a reason for hiding this comment

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

typo here

"postinstall": "yarn run gen:cahkra-theme-typings",
"test:lint": "eslint --ext .ts,.tsx ./src",
"test:prettier": "prettier --check ./src",
"prettier": "prettier --write ./src",
Expand All @@ -49,31 +50,59 @@
"react-dom": "^18.2.0",
"react-router-dom": "^6.3.0"
},
"dependencies": {
"@chakra-ui/anatomy": "^2.1.1",
"@chakra-ui/react": "^2.6.1",
"@chakra-ui/styled-system": "^2.9.0",
"@codemirror/view": "^6.9.5",
"@emotion/core": "^10.3.1",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@rebass/forms": "^4.0.6",
"@styled-system/css": "^5.1.5",
"@tanem/react-nprogress": "^5.0.34",
"@uiw/codemirror-extensions-langs": "^4.19.16",
"@uiw/codemirror-theme-darcula": "^4.19.16",
"@uiw/react-codemirror": "^4.19.16",
"date-fns": "^2.28.0",
"emotion-theming": "^10.3.0",
"framer-motion": "^10.11.4",
"ramda": "^0.28.0",
"rc-slider": "^10.1.0",
"rc-tooltip": "^4.2.3",
"react-datepicker": "4.10.0",
"react-spring": "^8.0.27",
"rebass": "^4.0.7"
},
"devDependencies": {
"@chakra-ui/cli": "^2.4.1",
"@playwright/experimental-ct-react": "^1.31.2",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.7",
"@semantic-release/npm": "^10.0.3",
"@semantic-release/release-notes-generator": "^10.0.3",
"@storybook/addon-actions": "^7.0.4",
"@storybook/addon-essentials": "^7.0.4",
"@storybook/addon-interactions": "^7.0.4",
"@storybook/addon-links": "^7.0.4",
"@storybook/react": "^7.0.4",
"@storybook/react-vite": "^7.0.4",
"@storybook/addon-actions": "^7.0.12",
"@storybook/addon-docs": "^7.0.12",
"@storybook/addon-essentials": "^7.0.12",
"@storybook/addon-interactions": "^7.0.12",
"@storybook/addon-links": "^7.0.12",
"@storybook/jest": "^0.1.0",
"@storybook/react": "^7.0.12",
"@storybook/react-vite": "^7.0.12",
"@storybook/test-runner": "^0.10.0",
"@storybook/testing-library": "^0.1.0",
"@types/node": "^16.12.38",
"@types/ramda": "^0.28.1",
"@types/react": "^18.0.28",
"@types/react-datepicker": "^4",
"@types/react-dom": "^18.0.11",
"@types/rebass": "^4.0.10",
"@types/rebass__forms": "^4.0.6",
"@typescript-eslint/eslint-plugin": "^5.29.0",
"@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^5.29.0",
"@vitejs/plugin-react": "^3.1.0",
"@vitejs/plugin-react": "^4.0.0",
"chromatic": "^5.10.2",
"commitizen": "^4.2.4",
"cross-env": "^7.0.3",
Expand All @@ -96,44 +125,18 @@
"react-dom": "^18.2.0",
"react-router-dom": "^6.3.0",
"semantic-release": "^21.0.1",
"storybook": "^7.0.4",
"storybook": "^7.0.12",
"storybook-dark-mode": "^3.0.0",
"typescript": "^4.6.2",
"vite": "^4.2.1",
"vite-plugin-css-injected-by-js": "^3.1.0",
"vite-plugin-dts": "^2.2.0",
"typescript": "^5.0.4",
"vite": "^4.3.6",
"vite-plugin-css-injected-by-js": "^3.1.1",
"vite-plugin-dts": "^2.3.0",
"yalc": "^1.0.0-pre.53"
},
"files": [
"dist",
".releaserc.json"
],
"dependencies": {
"@chakra-ui/react": "^2.6.1",
"@codemirror/view": "^6.9.5",
"@emotion/core": "^10.3.1",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@rebass/forms": "^4.0.6",
"@storybook/jest": "^0.1.0",
"@storybook/testing-library": "^0.1.0",
"@styled-system/css": "^5.1.5",
"@tanem/react-nprogress": "^5.0.34",
"@uiw/codemirror-extensions-langs": "^4.19.16",
"@uiw/codemirror-theme-darcula": "^4.19.16",
"@uiw/react-codemirror": "^4.19.16",
"date-fns": "^2.28.0",
"emotion-theming": "^10.3.0",
"events": "^3.2.0",
"framer-motion": "^10.11.4",
"ramda": "^0.28.0",
"rc-slider": "^10.1.0",
"rc-tooltip": "^4.2.3",
"react-datepicker": "4.10.0",
"react-spring": "^8.0.27",
"rebass": "^4.0.7",
"remove": "^0.1.5"
},
"publishConfig": {
"access": "public"
},
Expand Down
9 changes: 9 additions & 0 deletions src/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"nicholashsiang.vscode-react-snippet",
"eamodio.gitlens",
"ms-vsliveshare.vsliveshare"
]
}
3 changes: 3 additions & 0 deletions src/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
2 changes: 1 addition & 1 deletion src/chakra.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { useDisclosure, ColorModeScript } from '@chakra-ui/react';
export * from '@chakra-ui/react';

export { ChakraThemeProvider } from './theme-chakra/ChakraThemeProvider';

Expand Down
1 change: 1 addition & 0 deletions src/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const Button: FC<Props> = ({
const component = (
<RebassButton
variant={intent}
as={href ? 'span' : 'button'}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

both a Button and a tag are focusable components so using the keyboard Tab would visit the same component twice, this is to remove button when we have a tag

disabled={disabled || isLoading}
sx={{ ...S.wrapper, ...sx }}
type={type}
Expand Down
2 changes: 1 addition & 1 deletion src/components/button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const wrapper = {
},
} as SxStyleProp;

export const spinnerColor = (intent: string): string => {
export const spinnerColor = (intent: keyof typeof buttonsStyles): string => {
const disabledStyles = buttonsStyles[intent][':disabled'];
return disabledStyles.color;
};
42 changes: 14 additions & 28 deletions src/components/code/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EditorView } from '@codemirror/view';
import React, { FC, useState } from 'react';
import React, { useState } from 'react';
import { Box, Flex, FlexProps } from 'rebass';

import { LanguageName, loadLanguage } from '@uiw/codemirror-extensions-langs';
Expand Down Expand Up @@ -30,11 +30,10 @@ export interface CodeProps extends Omit<FlexProps, 'css' | 'title'> {
}

export const defaultPopupProps = {
width: 'calc(100vw - 80px)',
height: 'calc(100vh - 80px)',
size: '7xl',
};

const Code: FC<CodeProps> = ({
const Code = ({
content,
language,
copyButton = false,
Expand Down Expand Up @@ -62,11 +61,6 @@ const Code: FC<CodeProps> = ({
language={language}
copyButton={copyButton}
downloadButton={downloadButton}
maxHeightOfCode={
popupProps.height || popupProps.maxHeight
? `calc(${popupProps.height ?? popupProps.maxHeight} - 143px)`
: '100%'
}
{...props}
/>
)}
Expand Down Expand Up @@ -99,11 +93,8 @@ const Code: FC<CodeProps> = ({
export default Code;

// Normal Code Component
interface CodeSnippetProps
extends Omit<CodeProps, 'popupProps' | 'expandable'> {
maxHeightOfCode?: string;
}
const CodeSnippet: FC<CodeSnippetProps> = ({
type CodeSnippetProps = Omit<CodeProps, 'popupProps' | 'expandable'>;
const CodeSnippet = ({
title,
content,
language,
Expand All @@ -113,9 +104,8 @@ const CodeSnippet: FC<CodeSnippetProps> = ({
wrapLongLines,
showLineNumbers,
copyCallback,
maxHeightOfCode,
...props
}) => {
}: CodeSnippetProps) => {
return (
<Flex flexDirection="column" width="100%" height="100%">
<Flex width="100%" sx={codeHeaderStyles}>
Expand All @@ -133,13 +123,7 @@ const CodeSnippet: FC<CodeSnippetProps> = ({
<CopyButton content={content} copyCallback={copyCallback} />
)}
</Flex>
<Flex
width="100%"
variant="code"
height={maxHeightOfCode}
{...props}
p={0}
>
<Flex width="100%" variant="code" {...props} p={0}>
<CodeMirror
value={content}
basicSetup={{
Expand All @@ -162,9 +146,11 @@ const CodeSnippet: FC<CodeSnippetProps> = ({
};

// Download Button
const DownloadButton: FC<
Pick<CodeProps, 'content' | 'downloadCallback' | 'title'>
> = ({ content, downloadCallback, title }) => {
const DownloadButton = ({
content,
downloadCallback,
title,
}: Pick<CodeProps, 'content' | 'downloadCallback' | 'title'>) => {
const download = () => {
if (downloadCallback) {
downloadCallback();
Expand All @@ -186,10 +172,10 @@ const DownloadButton: FC<
};

// Copy Button
const CopyButton: FC<Pick<CodeProps, 'copyCallback' | 'content'>> = ({
const CopyButton = ({
copyCallback,
content,
}) => {
}: Pick<CodeProps, 'copyCallback' | 'content'>) => {
const [copied, setCopied] = useState(false);

const handleCopyClicked = async () => {
Expand Down
1 change: 1 addition & 0 deletions src/components/dropdown-button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
cursor: 'pointer',
marginTop: '-2px',
width: 'fit-content',
height: 'fit-content',
background: 'white',
},
dropdown: (height: number | undefined, alignLeft: boolean) => ({
Expand Down
23 changes: 9 additions & 14 deletions src/components/expand-viewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import React, { FC, useState } from 'react';
import { Box, Button as RebassButton, Flex } from 'rebass';
import { useTheme } from '../../theme/theme';
import Popup, { PopupProps } from '../popup';
import { IconButton } from '../icon-button';
import { getIcon, IconName } from '../icon/list';
import Value from '../typography/value';
import Subtitle from '../typography/subtitle';
import expandViewButtonStyle from './expand-viewer.styles';

export interface ExpandViewerProps {
Expand Down Expand Up @@ -45,18 +43,15 @@ const ExpandViewer: FC<ExpandViewerProps> = ({
return (
<Flex sx={{ width: '100%' }}>
<BriefComponent />
<Popup isOpen onClose={() => setExpanded(false)} {...popupProps}>
<Box padding={20}>
<Flex marginBottom={3} alignItems="center">
<Box flexGrow={1}>
<Subtitle>{title}</Subtitle>
</Box>
<IconButton
icon={IconName.cross}
intent="ghost"
onClick={() => setExpanded(false)}
/>
</Flex>
<Popup
isOpen
onClose={() => setExpanded(false)}
title={title}
hasCloseButton
size="4xl"
{...popupProps}
>
<Box mb="20px">
<NormalComponent />
</Box>
</Popup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const fileExplorerHeaderStyles = {
export default {
display: 'flex',
flexDirection: 'column',
minHeight: 'calc(100vh - 45px)',
maxHeight: 'calc(100vh - 20px)',
height: '100%',
maxHeight: 'calc(100vh - 110px)',
borderWidth: '1px',
borderBottomWidth: '0px',
borderStyle: 'solid',
Expand Down
3 changes: 3 additions & 0 deletions src/components/footer-button/footer-button.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ export default {
':disabled': {
cursor: 'default',
},
':focus': {
bg: 'primaryShade2',
},
} as SxStyleProp;
2 changes: 1 addition & 1 deletion src/components/navigation/container/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface NavigationProps {
children?: React.ReactNode;
footer?: React.ReactNode;
header?: React.ReactNode;
trackBy?: string;
trackBy?: keyof TreeNode;
tree?: TreeNode[];
onNavigate?: (node: TreeNode | null) => void;
onBackCLick?: () => void;
Expand Down
2 changes: 1 addition & 1 deletion src/components/navigation/context/getNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type ReturnType = TreeNode | null;

const getNode = (
tree: TreeNode[] | TreeNode,
key: string,
key: keyof TreeNode,
value?: string,
): ReturnType => {
if (Array.isArray(tree)) {
Expand Down
Loading