Skip to content

Commit

Permalink
Merge pull request #151 from osstotalsoft/ControlsAndExamplesUpdates
Browse files Browse the repository at this point in the history
Storybook controls and examples updates
  • Loading branch information
alexandra-c authored Dec 18, 2024
2 parents 30619c3 + de46580 commit 424e160
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/components/buttons/BackToButton/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { NavigateOptions } from 'react-router'
import { IconButtonProps } from '../IconButton/types'

export interface BackToButtonProps extends IconButtonProps {
export interface BackToButtonProps extends Omit<IconButtonProps, 'type'> {
/**
* Path where browser will be directed to when the button is clicked.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/UploadButton/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { IconButtonProps } from '../IconButton/types'
import { SvgIconComponent } from '@mui/icons-material'
import { F } from 'ts-toolbelt'
export interface UploadButtonProps extends IconButtonProps {
export interface UploadButtonProps extends Omit<IconButtonProps, 'type'> {
/**
* @default BackupIcon
* The Icon to display.
Expand Down
8 changes: 0 additions & 8 deletions src/components/feedback/Toast/ToastContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ const ToastContainer: React.FC<ToastContainerProps> = ({
}

ToastContainer.propTypes = {
/**
* Set the delay in ms to close the toast automatically.
* Use `false` to prevent the toast from closing.
* @default false
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
autoClose: PropTypes.oneOf([PropTypes.number, false]),
/**
* Limit the number of toast displayed at the same time
* @default 5
Expand Down
1 change: 0 additions & 1 deletion src/components/feedback/Toast/useToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const useToast = () => {
[classes[variant]]: variant,
[classes['default']]: true
})

const options: ToastOptionsBase = {
...restOptions,
transition: getTransitionType(transitionType),
Expand Down
29 changes: 29 additions & 0 deletions src/stories/feedback/Toast/TextSizePreview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) TotalSoft.
// This source code is licensed under the MIT license.

import React from 'react'
import { Button, ToastContainer, useToast } from 'components'
import Grid from '@mui/material/Grid2'

const TextSizePreview = (args: any) => {
const addToast = useToast()

return (
<Grid container spacing={2} justifyItems={'flex-start'}>
<ToastContainer {...args} />
<Button
size={'small'}
color={'primary'}
onClick={() =>
addToast('This message font will change if you change textSize property of ToastContainer!', 'success', {
...args
})
}
>
{'Change text size from controls.'}
</Button>
</Grid>
)
}

export default TextSizePreview
36 changes: 34 additions & 2 deletions src/stories/feedback/Toast/Toast.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import VariantsPreview from './VariantsPreview'
import PositionsPreview from './PositionsPreview'
import TransitionsPreview from './TransitionsPreview'
import ActionsPreview from './ActionsPreview'
import TextSizePreview from './TextSizePreview'

const meta: Meta<typeof ToastContainer> = {
title: 'Components/Feedback/Toast',
Expand Down Expand Up @@ -113,7 +114,7 @@ export const Variants: Story = {
}
}
},
render: args => <VariantsPreview {...args} />
render: args => <VariantsPreview {...args} />
}
/**
* Different positions are available for rendering toast.
Expand Down Expand Up @@ -188,7 +189,7 @@ export const Positions: Story = {
}
}
},
render: args => <PositionsPreview {...args}/>
render: args => <PositionsPreview {...args} />
}

/**
Expand Down Expand Up @@ -290,3 +291,34 @@ export const Actions: Story = {
},
render: args => <ActionsPreview {...args} />
}

/**
* You can change the content font size by changing the ToastContainer textSize parameter of the application
* Available options are:
* - small
* - medium
* - large
* Default is set to 'small'.
*/
export const TextSize: Story = {
parameters: {
docs: {
source: {
code: ` <ToastContainer textSize={textSize} />
<Button
size={'small'}
color={'primary'}
onClick={() =>
addToast('This message font will change if you change textSize property of ToastContainer!', 'success', {
...args
})
}
>
{'Change text size from controls.'}
</Button>`,
format: true
}
}
},
render: args => <TextSizePreview {...args} />
}
1 change: 0 additions & 1 deletion src/stories/surfaces/Accordion/Accordion.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ export const Actions: Story = {
options={options}
value={value}
onChange={handleChange}
stopEventPropagation
/>
</Grid>
<Grid size={{ lg: 1 }}>
Expand Down
1 change: 0 additions & 1 deletion src/stories/surfaces/Accordion/ActionsPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const ActionsPreview = () => {
options={options}
value={value}
onChange={handleChange}
stopEventPropagation
isClearable
/>
<Typography>{`Selected value: ${JSON.stringify(value)}`}</Typography>
Expand Down
1 change: 0 additions & 1 deletion src/stories/surfaces/Card/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const actions = (
*/
export const Card: Story = {
args: { title, subheader, children, icon: People, footer, actions },

parameters: {
docs: {
source: {
Expand Down
4 changes: 2 additions & 2 deletions src/stories/surfaces/CollapseCard/CollapseCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const Filled: Story = {
}
}
},
render: () => <FilledPreview />
render: args => <FilledPreview {...args} />
}

/**
Expand Down Expand Up @@ -178,7 +178,7 @@ export const Controlled: Story = {
}
}
},
render: () => <ControlledPreview />
render: args => <ControlledPreview {...args} />
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/stories/surfaces/CollapseCard/ControlledPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const uncontrolled = `
}
`

const ControlledPreview = () => {
const ControlledPreview = (args: any) => {
const [expanded, setExpanded] = useState(false)
const handleToggle = useCallback(() => setExpanded(current => !current), [])

Expand All @@ -55,6 +55,7 @@ const ControlledPreview = () => {
<QuestionMark fontSize="small" />
</IconButton>
}
{...args}
/>
</Grid>
<Grid size={4}>
Expand Down
3 changes: 2 additions & 1 deletion src/stories/surfaces/CollapseCard/FilledPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button, IconButton, Typography, CollapseCard } from 'components'
import QuestionMark from '@mui/icons-material/QuestionMark'
import { Grid2 as Grid, TextField } from '@mui/material'

const FilledPreview = () => {
const FilledPreview = (args: any) => {
return (
<CollapseCard
filled
Expand All @@ -18,6 +18,7 @@ const FilledPreview = () => {
<QuestionMark fontSize="small" />
</IconButton>
}
{...args}
>
<Grid container rowSpacing={3} justifyContent="center">
<Grid size={8}>
Expand Down
7 changes: 4 additions & 3 deletions src/stories/surfaces/StatsCard/StatsCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const Default: Story = {
* Stats Card component allows displaying any type of data, string, numeric, React Node, etc.
*/
export const VariousContents: Story = {
args: { icon, title, footer },
parameters: {
controls: { hideNoControlsWarning: true },
docs: {
Expand Down Expand Up @@ -86,11 +87,11 @@ export const VariousContents: Story = {
}
}
},
render: () => (
render: args => (
<>
<StatsCardComponent {...Default.args} description={'4.39 $'} />
<StatsCardComponent {...args} description={'4.39 $'} />
<StatsCardComponent
{...Default.args}
{...args}
icon={Group}
description={
<>
Expand Down

0 comments on commit 424e160

Please sign in to comment.