-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from IvanRuskevych/Ruskevych/InputAnnotation
feat: InputAnnotation component & stories
- Loading branch information
Showing
9 changed files
with
85 additions
and
13 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
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
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,6 @@ | ||
export type textOptionsType = "description" | "error"; | ||
|
||
export interface InputAnnotationProps { | ||
text: string; | ||
textOptions: textOptionsType; | ||
} |
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,2 +1,3 @@ | ||
export * from "./Theme.types.ts"; | ||
export * from "./InputLabel.types.ts"; | ||
export * from "./InputAnnotation.types.ts"; |
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,17 @@ | ||
import styled from "styled-components"; | ||
|
||
export const StyledParagraph = styled.p<{ | ||
textOptions: "description" | "error"; | ||
}>` | ||
color: ${({ textOptions, theme }) => | ||
textOptions === "description" | ||
? theme.colors.textSecondary | ||
: theme.colors.error}; | ||
/* Text xxs/Regular */ | ||
font-family: Inter, sans-serif; | ||
font-size: 12px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: 20px; /* 166.667% */ | ||
`; |
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,10 @@ | ||
import { FC } from "react"; | ||
import { StyledParagraph } from "./InputAnnotation.styles.ts"; | ||
import { InputAnnotationProps } from "../../types"; | ||
|
||
export const InputAnnotation: FC<InputAnnotationProps> = ({ | ||
text, | ||
textOptions, | ||
}) => { | ||
return <StyledParagraph textOptions={textOptions}>{text}</StyledParagraph>; | ||
}; |
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 +1,2 @@ | ||
export * from "./InputLabel/InputLabel.tsx"; | ||
export * from "./InputAnnotation/InputAnnotation.tsx"; |
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,37 @@ | ||
import { Meta, StoryFn } from "@storybook/react"; | ||
import { ThemeProvider } from "styled-components"; | ||
|
||
import { InputAnnotationProps } from "../shared/types"; | ||
import { InputAnnotation } from "../shared/ui"; | ||
import { darkTheme, lightTheme } from "../shared/styles"; | ||
|
||
const meta: Meta = { | ||
title: "Components/InputAnnotation", | ||
component: InputAnnotation, | ||
argTypes: { | ||
text: { control: "text" }, | ||
textOptions: { control: "radio", options: ["description", "error"] }, | ||
theme: { control: "radio", options: ["light", "dark"] }, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: StoryFn<InputAnnotationProps & { theme: "light" | "dark" }> = ( | ||
args, | ||
) => { | ||
const selectedTheme = args.theme === "light" ? lightTheme : darkTheme; | ||
|
||
return ( | ||
<ThemeProvider theme={selectedTheme}> | ||
<InputAnnotation {...args} /> | ||
</ThemeProvider> | ||
); | ||
}; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
text: "This is a hint text to help user.", | ||
textOptions: "description", | ||
theme: "light", | ||
}; |
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