-
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 #62 from etchteam/feature/etch-369-help-text-for-i…
…nputs Help text component
- Loading branch information
Showing
7 changed files
with
122 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diamond-help-text { | ||
color: var(--diamond-help-text-color); | ||
font-size: var(--diamond-help-text-font-size); | ||
|
||
&[state='valid'] { | ||
color: var(--diamond-help-text-color-valid); | ||
} | ||
|
||
&[state='invalid'] { | ||
color: var(--diamond-help-text-color-invalid); | ||
} | ||
} |
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,66 @@ | ||
import { StoryObj } from '@storybook/web-components'; | ||
import { html } from 'lit'; | ||
|
||
import './HelpText'; | ||
import '../Icon/Icon'; | ||
|
||
export default { | ||
component: 'diamond-help-text', | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: | ||
'A piece of text to provide additional information or context for form inputs, including form validation messages.', | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
state: { | ||
control: { | ||
type: 'select', | ||
}, | ||
options: ['valid', 'invalid'], | ||
}, | ||
}, | ||
}; | ||
|
||
export const HelpText: StoryObj = { | ||
render: ({ state }) => html` | ||
<diamond-help-text state="${state}"> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod | ||
tempor incididunt ut labore et dolore magna aliqua. | ||
</diamond-help-text> | ||
`, | ||
}; | ||
|
||
HelpText.args = { | ||
state: '', | ||
}; | ||
|
||
export const HelpTextWithFormatting: StoryObj = { | ||
render: ({ state }) => html` | ||
<diamond-help-text state="${state}" class="diamond-text-size-md"> | ||
<a href="#">Lorem ipsum</a> | ||
dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor | ||
incididunt ut labore et | ||
<span class="diamond-text-weight-bold">dolore magna aliqua.</span> | ||
</diamond-help-text> | ||
`, | ||
}; | ||
|
||
export const HelpTextWithIcon: StoryObj = { | ||
render: ({ state }) => html` | ||
<diamond-help-text state="${state}"> | ||
<diamond-icon> | ||
<svg fill="none" viewBox="0 0 24 24" height="24" width="24"> | ||
<path | ||
d="M2 6C2 4.89543 2.89543 4 4 4H20C21.1046 4 22 4.89543 22 6V18C22 19.1046 21.1046 20 20 20H4C2.89543 20 2 19.1046 2 18V6ZM5.51859 6L12 11.6712L18.4814 6H5.51859ZM20 7.32877L12.6585 13.7526C12.2815 14.0825 11.7185 14.0825 11.3415 13.7526L4 7.32877V18H20V7.32877Z" | ||
fill="currentColor" | ||
></path> | ||
</svg> | ||
</diamond-icon> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod | ||
tempor incididunt ut labore et dolore magna aliqua. | ||
</diamond-help-text> | ||
`, | ||
}; |
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,19 @@ | ||
import { JSXCustomElement } from '../../../types/jsx-custom-element'; | ||
|
||
export interface HelpTextAttributes { | ||
state?: 'valid' | 'invalid'; | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'diamond-help-text': HelpTextAttributes; | ||
} | ||
} | ||
|
||
declare module 'react' { | ||
namespace JSX { | ||
interface IntrinsicElements { | ||
'diamond-help-text': JSXCustomElement<HelpTextAttributes>; | ||
} | ||
} | ||
} |
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