This repository has been archived by the owner on Apr 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Migrate < Link />, < StoryDescription /> to ts (#83)
Co-authored-by: Sergey Roytman <[email protected]>
- Loading branch information
1 parent
4785792
commit bc4ee34
Showing
6 changed files
with
127 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { FC } from 'react'; | ||
import Link from '../link/link'; | ||
import Tip from '../tip/tip'; | ||
|
||
interface DeprecatedWarningProps { | ||
alternativeName: string; | ||
alternativeLink?: string; | ||
} | ||
|
||
const DeprecatedWarning: FC<DeprecatedWarningProps> = ({ alternativeName, alternativeLink }) => ( | ||
<Tip emoji="🚨" title="Deprecated component" type={Tip.types.DANGER}> | ||
<> | ||
This is a legacy component and will be deprecated in the next major version. Please consider using the | ||
<Link href={alternativeLink} size={Link.sizes.SMALL}> | ||
{alternativeName} | ||
</Link> | ||
component for your needs instead. | ||
</> | ||
</Tip> | ||
); | ||
|
||
export default DeprecatedWarning; | ||
import { FC } from 'react'; | ||
import Link from '../link/link'; | ||
import Tip from '../tip/tip'; | ||
|
||
interface DeprecatedWarningProps { | ||
alternativeName: string; | ||
alternativeLink: string; | ||
} | ||
|
||
const DeprecatedWarning: FC<DeprecatedWarningProps> = ({ alternativeName, alternativeLink }) => ( | ||
<Tip emoji="🚨" title="Deprecated component" type={Tip.types.DANGER}> | ||
<> | ||
This is a legacy component and will be deprecated in the next major version. Please consider using the | ||
<Link href={alternativeLink} size={Link.sizes.SMALL}> | ||
{alternativeName} | ||
</Link> | ||
component for your needs instead. | ||
</> | ||
</Tip> | ||
); | ||
|
||
export default DeprecatedWarning; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum LinkSize { | ||
SMALL = 'small', | ||
MEDIUM = 'medium', | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { FC } from 'react'; | ||
import cx from 'classnames'; | ||
import CoreLink from '../../helpers/components/Link/Link'; | ||
import styles from './link.module.scss'; | ||
import { LinkSize } from './LinkConstants'; | ||
import { withStaticProps } from '../../types'; | ||
|
||
type LinkProps = { | ||
className?: string; | ||
children: string; | ||
href: string; | ||
size?: LinkSize; | ||
withoutSpacing?: boolean; | ||
}; | ||
|
||
const Link: FC<LinkProps> & { sizes?: typeof LinkSize } = ({ | ||
children, | ||
href, | ||
size = Link.sizes?.MEDIUM, | ||
withoutSpacing = false, | ||
className, | ||
}) => ( | ||
<CoreLink | ||
text={children} | ||
href={href} | ||
className={cx(styles.compsLink, className, { | ||
[styles.small]: size === Link.sizes?.SMALL, | ||
[styles.medium]: size === Link.sizes?.MEDIUM, | ||
[styles.withSpacing]: !withoutSpacing, | ||
})} | ||
/> | ||
); | ||
|
||
export default withStaticProps(Link, { sizes: LinkSize }); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { FC, useMemo } from 'react'; | ||
import cx from 'classnames'; | ||
import styles from './story-description.module.scss'; | ||
import { ElementContent, withStaticProps } from '../../types'; | ||
import { FlexAlign, FlexDirection, FlexGap, FlexJustify } from '../../helpers/components/Flex/FlexConstants'; | ||
import Flex from '../../helpers/components/Flex/Flex'; | ||
|
||
type StoryDescriptionProps = { | ||
align?: FlexAlign; | ||
description?: ElementContent; | ||
children: ElementContent; | ||
className: string; | ||
headerAlign?: FlexAlign; | ||
headerJustify?: FlexJustify; | ||
headerStyle: React.CSSProperties; | ||
justify?: FlexJustify; | ||
vertical?: boolean; | ||
}; | ||
|
||
const StoryDescription: FC<StoryDescriptionProps> & { | ||
justify?: typeof FlexJustify; | ||
align?: typeof FlexAlign; | ||
gaps?: typeof FlexGap; | ||
directions?: typeof FlexDirection; | ||
} = ({ | ||
description = '', | ||
headerStyle, | ||
children, | ||
vertical = false, | ||
className, | ||
align, | ||
justify = StoryDescription.justify?.START, | ||
headerAlign, | ||
headerJustify, | ||
}) => { | ||
const direction = useMemo( | ||
() => (vertical ? StoryDescription.directions?.COLUMN : StoryDescription.directions?.ROW), | ||
[vertical], | ||
); | ||
|
||
return ( | ||
<Flex | ||
direction={direction} | ||
gap={StoryDescription.gaps?.MEDIUM} | ||
justify={justify} | ||
align={align || undefined} | ||
className={className} | ||
> | ||
<Flex | ||
className={cx(styles.description, { [styles.vertical]: vertical })} | ||
style={{ width: '120px', ...headerStyle }} | ||
justify={headerJustify} | ||
align={headerAlign || StoryDescription.align?.CENTER} | ||
> | ||
{description} | ||
</Flex> | ||
{children} | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default withStaticProps(StoryDescription, { | ||
justify: FlexJustify, | ||
align: FlexAlign, | ||
gaps: FlexGap, | ||
directions: FlexDirection, | ||
}); |