Skip to content

Commit

Permalink
fix: fix ts erros
Browse files Browse the repository at this point in the history
  • Loading branch information
gabyzif committed Sep 20, 2024
1 parent 54c96e6 commit 90864de
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/components/data-entry/Checkbox/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { type StoryObj } from '@storybook/react'
import { Checkbox, Divider } from 'src/components'
import { useState } from 'react'
import { ExampleStory } from 'src/utils/ExampleStory'
import { type CheckboxValueType } from 'antd/es/checkbox/Group'
import { type ICheckboxProps } from 'src/components/data-entry/Checkbox/Checkbox'
import { userEvent } from '@storybook/test'
import { expect } from '@storybook/test'

export type CheckboxValueType = string | number | boolean

const meta: Meta<typeof Checkbox> = {
title: 'Aquarium/Data Entry/Checkbox',
component: props => {
Expand Down
20 changes: 14 additions & 6 deletions src/components/feedback/Watermark/Watermark.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const ExampleMultiline: Story = {

export const ExampleConfig: Story = {
render: () => {
type Color = GetProp<IColorPickerProps, 'color'>
type Color = GetProp<IColorPickerProps, 'value'>

interface WatermarkConfig {
content: string
Expand Down Expand Up @@ -144,7 +144,15 @@ export const ExampleConfig: Story = {
rotate,
gap,
offset,
font: { color: typeof color === 'string' ? color : color.toRgbString(), fontSize },
font: {
color:
typeof color === 'string'
? color
: typeof color === 'object' && 'toRgbString' in color
? color.toRgbString()
: String(color),
fontSize,
},
}

return (
Expand All @@ -153,8 +161,8 @@ export const ExampleConfig: Story = {
<Watermark {...watermarkProps}>
<Typography.Paragraph>
The light-speed iteration of the digital world makes products more complex. However, human consciousness
and attention resources are limited. Facing this design contradiction, the pursuit of natural
interaction will be the consistent direction of Ant Design.
and attention resources are limited. Facing this design contradiction, the pursuit of natural interaction
will be the consistent direction of Ant Design.
</Typography.Paragraph>
<Typography.Paragraph>
Natural user cognition: According to cognitive psychology, about 80% of external information is obtained
Expand All @@ -169,8 +177,8 @@ export const ExampleConfig: Story = {
relationship between users, system roles, and task objectives, and also contextually organize system
functions and services. At the same time, a series of methods such as behavior analysis, artificial
intelligence and sensors could be applied to assist users to make effective decisions and reduce extra
operations of users, to save users&apos; mental and physical resources and make human-computer
interaction more natural.
operations of users, to save users&apos; mental and physical resources and make human-computer interaction
more natural.
</Typography.Paragraph>
<img
style={{ zIndex: 10, width: '100%', maxWidth: 800, position: 'relative' }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MenuItemType } from 'antd/es/menu/hooks/useItems'
import type { MenuItemGroupType } from 'antd/es/menu/hooks/useItems'
import { type MenuProps } from 'antd'

import { Icon } from 'src/components'
import { Center } from 'src/components'
import { Menu } from 'src/components'
Expand All @@ -10,6 +10,8 @@ import { Tooltip } from 'src/components'
import { Spin } from 'src/components'
import { type IMenuInfo } from 'src/components'

export type MenuItemType = Required<MenuProps>['items'][number]
export type MenuItemGroupType = Required<MenuProps>['items'][number] // Same as menu item type
export interface INavigationCreateProps {
createItems: Array<INavigationCreateItem | INavigationCreateGroup>
}
Expand All @@ -20,6 +22,7 @@ export interface INavigationCreateGroup extends Omit<MenuItemGroupType, 'key'> {
}

export interface INavigationCreateItem extends Omit<MenuItemType, 'key'> {
disabled?: boolean
title: string
description: string
type?: undefined
Expand Down
6 changes: 4 additions & 2 deletions src/components/navigation/GlobalNavigation/NavigationList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Menu } from 'src/components'
import type { MenuItemGroupType } from 'antd/es/menu/hooks/useItems'
import { type MenuProps } from 'antd'
import { NavigationIcon } from 'src/components/navigation/GlobalNavigation/NavigationIcon'
import { NavigationItem } from 'src/components/navigation/GlobalNavigation/NavigationItem'
import { Center } from 'src/components'
Expand All @@ -9,6 +9,8 @@ import { Fragment } from 'react'
import { buildLinkFromHrefOptions } from 'src/utils/utils'
import { NavigationButtonItem } from 'src/components/navigation/GlobalNavigation/NavigationButtonItem'

export type MenuItemGroupType = Required<MenuProps>['items'][number] // This works for both groups and items

export interface INavigationListProps {
items: IGlobalNavigationItem[]
}
Expand Down Expand Up @@ -44,7 +46,7 @@ function generateMenuItem(item: IGlobalNavigationItem, i: number) {
if (child.type !== 'button') {
children.push(child)
} else {
const buttonKey = `submenu-button-${children.filter(c => c.type === 'button').length}-${index}`
const buttonKey = `submenu-button-${children.filter(c => c !== null && c.type === 'button').length}-${index}`

children.push({
className: 'globalNavigation__buttonItem',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface INavigationWorkspace extends IWorkspaceSelectorItem {
}

export interface IWorkspaceSelectorDisplayItem extends MenuItemType {
key: string | null | undefined
type: 'org' | 'account' | 'workspace'
className: string
label: ReactNode
Expand Down
13 changes: 6 additions & 7 deletions src/components/navigation/Menu/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Menu as AntMenu } from 'antd'
import { Menu as AntMenu, type MenuProps } from 'antd'
import { type MenuProps as AntMenuProps } from 'antd'
import {
type MenuItemType as AndMenuItemType,
type MenuItemGroupType as AndMenuItemGroupType,
type MenuDividerType as AndMenuDividerType,
type SubMenuType as AndSubMenuType,
} from 'antd/es/menu/hooks/useItems'
import { type MenuInfo as RCMenuInfo } from 'rc-menu/lib/interface'
import { ConfigProvider } from 'src/components'

export type AndMenuItemType = Required<MenuProps>['items'][number]
export type AndMenuItemGroupType = Required<MenuProps>['items'][number] // Same type used for menu groups
export type AndMenuDividerType = Required<MenuProps>['items'][number] // Menu divider uses the same type
export type AndSubMenuType = Required<MenuProps>['items'][number] // Submenu is also part of 'items'

export interface IMenuProps extends AntMenuProps {}

export interface IMenuInfo extends RCMenuInfo {}
Expand Down

0 comments on commit 90864de

Please sign in to comment.