Skip to content

Commit

Permalink
refactor: review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-ivanovvv committed May 20, 2024
1 parent 9bc06d1 commit 5659cb9
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 72 deletions.
14 changes: 10 additions & 4 deletions app/entrypoints/renderer/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import React from 'react'
'use client'

import React from 'react'

import { ThemeProvider } from '@ui/theme'

const RootLayout = ({ children }) => (
<html>
<body>{children}</body>
</html>
<ThemeProvider>
<html>
<body>{children}</body>
</html>
</ThemeProvider>
)

export default RootLayout
6 changes: 2 additions & 4 deletions app/entrypoints/renderer/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use client'

import React from 'react'
import React from 'react'

import { ThemeProvider } from '@ui/theme'

const Page = () => <ThemeProvider>page</ThemeProvider>
const Page = () => <>page</>

export default Page
5 changes: 3 additions & 2 deletions ui/dropdown/src/button/button.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Box } from '@atls-ui-parts/layout'

import React from 'react'
import { FC } from 'react'
import { PropsWithChildren } from 'react'
import { useHover } from 'react-laag'

import { DropdownButtonProps } from './button.interfaces'
Expand All @@ -18,7 +19,7 @@ const DropdownButtonContainer = styled(Box)<DropdownButtonContainerProps>(
appearanceButtonStyles
)

export const DropdownButton: FC<DropdownButtonProps> = ({
export const DropdownButton: FC<PropsWithChildren<DropdownButtonProps>> = ({
triggerProps,
onClick,
isOpen,
Expand All @@ -34,7 +35,7 @@ export const DropdownButton: FC<DropdownButtonProps> = ({
hover={hover}
{...hoverProps}
>
<DotComponent />
<DotComponent count={3} />
{children}
</DropdownButtonContainer>
)
Expand Down
7 changes: 3 additions & 4 deletions ui/dropdown/src/button/button.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { BoxProps } from '@atls-ui-parts/layout'
import { BoxProps } from '@atls-ui-parts/layout'

import { JSX } from 'react'
import { TriggerProps } from 'react-laag'

export interface DropdownButtonProps extends BoxProps {
children?: JSX.Element | string
triggerProps: object
triggerProps: TriggerProps
onClick: VoidFunction
isOpen: boolean
}
Expand Down
2 changes: 1 addition & 1 deletion ui/dropdown/src/button/button.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const baseButtonStyles: styleFn = ({ theme }) => ({
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
gap: 3,
gap: theme.spaces.dropdown.button.gap,
})

export const sizeButtonStyles: styleFn = ({ theme }) => ({
Expand Down
11 changes: 5 additions & 6 deletions ui/dropdown/src/button/dot/dot.component.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import styled from '@emotion/styled'
import { Box } from '@atls-ui-parts/layout'
import { BoxProps } from '@atls-ui-parts/layout'

import React from 'react'
import { FunctionComponent } from 'react'
import { FC } from 'react'

import { DotProps } from './dot.iterfaces'
import { sizeDotStyles } from './dot.styles'
import { appearanceDotStyles } from './dot.styles'

const Dot = styled(Box)<any>(sizeDotStyles, appearanceDotStyles)
const Dot = styled(Box)<BoxProps>(sizeDotStyles, appearanceDotStyles)

export const DotComponent: FunctionComponent<any> = () => {
const dotsCount = 3
return Array(dotsCount).fill(<Dot />)
}
export const DotComponent: FC<DotProps> = ({ count }) => Array(count).fill(<Dot />)
3 changes: 3 additions & 0 deletions ui/dropdown/src/button/dot/dot.iterfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface DotProps {
count: number
}
8 changes: 6 additions & 2 deletions ui/dropdown/src/child-container/child-container.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Box } from '@atls-ui-parts/layout'

import React from 'react'
import { FC } from 'react'
import { PropsWithChildren } from 'react'

import { ChildContainerProps } from './child-container.interfaces'
import { baseChildContainerStyles } from './child-container.styles'
Expand All @@ -15,8 +16,11 @@ const StyledBox = styled(Box)<any>(
appearanceChildContainerStyles
)

export const ChildContainer: FC<ChildContainerProps> = ({ layerProps, children }) => {
const childrenContainerHandler = (e) => {
export const ChildContainer: FC<PropsWithChildren<ChildContainerProps>> = ({
layerProps,
children,
}) => {
const childrenContainerHandler = (e: Event): void => {
e.stopPropagation()
}

Expand Down
5 changes: 2 additions & 3 deletions ui/dropdown/src/child-container/child-container.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { JSX } from 'react'
import { LayerProps } from 'react-laag'

export interface ChildContainerProps {
layerProps: object
children: JSX.Element
layerProps: LayerProps
}
24 changes: 12 additions & 12 deletions ui/dropdown/src/dropdown.component.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Box } from '@atls-ui-parts/layout'
import { Box } from '@atls-ui-parts/layout'

import React from 'react'
import { FC } from 'react'
import { useState } from 'react'
import { useLayer } from 'react-laag'
import React from 'react'
import { FC } from 'react'
import { PropsWithChildren } from 'react'
import { useState } from 'react'
import { useLayer } from 'react-laag'

import { DropdownButton } from './button/button.component'
import { ChildContainer } from './child-container'
import { DropdownProps } from './dropdown.interface'
import { DropdownButton } from './button/button.component'
import { ChildContainer } from './child-container'
import { DropdownProps } from './dropdown.interface'

export const Dropdown: FC<DropdownProps> = ({ children }) => {
export const Dropdown: FC<PropsWithChildren<DropdownProps>> = ({ children }) => {
const [isOpen, setOpen] = useState(false)

const buttonClickHandler = () => setOpen(!isOpen)
Expand All @@ -28,11 +29,10 @@ export const Dropdown: FC<DropdownProps> = ({ children }) => {
})

return (
<>
<DropdownButton triggerProps={triggerProps} isOpen={isOpen} onClick={buttonClickHandler} />
<DropdownButton triggerProps={triggerProps} isOpen={isOpen} onClick={buttonClickHandler}>
{renderLayer(
<Box>{isOpen && <ChildContainer layerProps={layerProps}>{children}</ChildContainer>}</Box>
)}
</>
</DropdownButton>
)
}
7 changes: 1 addition & 6 deletions ui/dropdown/src/dropdown.interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
import { InputHTMLAttributes } from 'react'
import { JSX } from 'react'

export interface DropdownProps extends Omit<InputHTMLAttributes<any>, 'onChange'> {
children: JSX.Element
}
export interface DropdownProps {}
2 changes: 1 addition & 1 deletion ui/input/src/input.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { switchProp } from 'styled-tools'
export const shapeStyles: styleFn = ({ theme }) => ({
fontFamily: theme.fonts.primary,
size: 52,
fontWeight: 400,
fontWeight: theme.fontWeight.normal,
fontSize: theme.fontSizes.small.semiLarge,
borderRadius: theme.radii.f9,
padding: theme.spaces.input.padding,
Expand Down
18 changes: 11 additions & 7 deletions ui/modal/src/child-container/child-container.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ export const baseChildContainerStyles: styleFn = ({ theme }) => ({
WebkitTapHighlightColor: 'transparent',
})

export const sizeChildContainerStyles: styleFn = () => ({
width: '486px',
height: 'min-content',
maxWidth: 'calc(100% - 24px)',
maxHeight: 'calc(100% - 24px)',
margin: 'auto',
padding: '12px 24px',
const WIDTH = '486px'
const HEIGHT = 'min-content'
const MAX_WIDTH = 'calc(100% - 24px)'
const MAX_HEIGHT = 'calc(100% - 24px)'
export const sizeChildContainerStyles: styleFn = ({ theme }) => ({
width: WIDTH,
height: HEIGHT,
maxWidth: MAX_WIDTH,
maxHeight: MAX_HEIGHT,
margin: theme.spaces.modal.childContainer.margin,
padding: theme.spaces.modal.childContainer.padding,
})

export const appearanceChildContainerStyles: styleFn = ({ theme }) => ({
Expand Down
22 changes: 12 additions & 10 deletions ui/modal/src/modal.component.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { Condition } from '@atls-ui-parts/condition'
import { Portal } from '@atls-ui-parts/portal'
import { Condition } from '@atls-ui-parts/condition'
import { Portal } from '@atls-ui-parts/portal'

import React from 'react'
import { FC } from 'react'
import React from 'react'
import { FC } from 'react'
import { PropsWithChildren } from 'react'
import { MouseEventHandler } from 'react'

import { Backdrop } from './backdrop'
import { ChildContainer } from './child-container'
import { Container } from './container'
import { ModalProps } from './modal.interfaces'
import { Backdrop } from './backdrop'
import { ChildContainer } from './child-container'
import { Container } from './container'
import { ModalProps } from './modal.interfaces'

const Modal: FC<ModalProps> = ({ children, open }) => {
const childrenContainerHandler = (e) => {
const Modal: FC<PropsWithChildren<ModalProps>> = ({ children, open }) => {
const childrenContainerHandler: MouseEventHandler<HTMLDivElement> = (e) => {
e.stopPropagation()
}

Expand Down
3 changes: 0 additions & 3 deletions ui/modal/src/modal.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { JSX } from 'react'

export interface ModalProps {
open: boolean
children: JSX.Element
}
3 changes: 2 additions & 1 deletion ui/switch/src/icon-switch/icon-switch.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useSwitch } from '@atls-ui-parts/switch'

import React from 'react'
import { FC } from 'react'
import { PropsWithChildren } from 'react'
import { useRef } from 'react'

import { IconSwitchProps } from './icon-switch.interfaces'
Expand All @@ -18,7 +19,7 @@ const IconSwitchContainer = styled(HandleElement)(
shapeHandleStyles
)

const IconSwitch: FC<IconSwitchProps> = ({
const IconSwitch: FC<PropsWithChildren<IconSwitchProps>> = ({
disabled = false,
checked: defaultValue,
onChange,
Expand Down
4 changes: 1 addition & 3 deletions ui/switch/src/icon-switch/icon-switch.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { SwitchProps } from '@atls-ui-parts/switch'

export interface IconSwitchProps extends SwitchProps {
children: JSX.Element
}
export interface IconSwitchProps extends SwitchProps {}
3 changes: 2 additions & 1 deletion ui/switch/src/theme-switch/thumb/thumb.element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Box } from '@atls-ui-parts/layout'

import React from 'react'
import { FC } from 'react'
import { PropsWithChildren } from 'react'

import { ThumbElementProps } from './thumb.interfaces'
import { baseThumbStyles } from './thumb.styles'
Expand All @@ -17,7 +18,7 @@ const ThumbElementContainer = styled(Box)<any>(
appearanceThumbStyles
)

const ThumbElement: FC<ThumbElementProps> = ({ checked, hover, children }) => (
const ThumbElement: FC<PropsWithChildren<ThumbElementProps>> = ({ checked, hover, children }) => (
<ThumbElementContainer checked={checked} hover={hover}>
{children}
</ThumbElementContainer>
Expand Down
1 change: 0 additions & 1 deletion ui/switch/src/theme-switch/thumb/thumb.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ThumbElementProps as BaseThumbElementProps } from '@atls-ui-parts/switc
export interface ThumbElementProps extends BaseThumbElementProps {
active: boolean
hover: boolean
children: JSX.Element
}

export interface ThumbComponentProps extends BaseThumbElementProps {
Expand Down
5 changes: 4 additions & 1 deletion ui/theme/src/theme/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ export const spaces = {
button: {
width: 40,
height: 28,
gap: 3,
},
},
input: {
padding: 18,
},
modal: {
constainer: {
container: {
position: 'fixed',
zIndex: 1300,
bottom: 0,
Expand All @@ -35,6 +36,8 @@ export const spaces = {
right: 0,
},
childContainer: {
margin: 'auto',
padding: '12px 24px',
position: 'fixed',
display: 'flex',
flexDirection: 'column',
Expand Down

0 comments on commit 5659cb9

Please sign in to comment.