Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit

Permalink
feat(helperText): add support for helper text
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-capsule42 committed Nov 24, 2021
1 parent 061ac17 commit 91648dd
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
65 changes: 65 additions & 0 deletions demo/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,71 @@ _Note: best combined with bordered attribute_

</auro-accordion>

## Example using helperText attribute

<div class="exampleWrapper">
<auro-dropdown inset bordered rounded>
<span>
Lorem ipsum solar
</span>
<span slot="helperText">
Helper text
</span>
<div slot="trigger">
Trigger
</div>
</auro-dropdown>
</div>

<auro-accordion lowProfile justifyRight>
<span slot="trigger">See code</span>

```html
<auro-dropdown inset bordered rounded helperText="Helper text">
<span>
Lorem ipsum solar
</span>
<div slot="trigger">
Trigger
</div>
</auro-dropdown>
```

</auro-accordion>

<div class="exampleWrapper">
<auro-dropdown inset bordered rounded error>
<span>
Lorem ipsum solar
</span>
<span slot="helperText">
Helper text
</span>
<div slot="trigger">
Trigger
</div>
</auro-dropdown>
</div>

<auro-accordion lowProfile justifyRight>
<span slot="trigger">See code</span>

```html
<auro-dropdown inset bordered rounded error>
<span>
Lorem ipsum solar
</span>
<span slot="helperText">
Helper text
</span>
<div slot="trigger">
Trigger
</div>
</auro-dropdown>
```

</auro-accordion>

## Examples with custom dimensions

The `auro-dropdown` trigger will fill 100% of the available width of it's parent container. The dropdown content will always be at least as wide as the trigger. If the container is narrower than the desired width of the dropdown content (e.g. using just an icon for the trigger) you may apply CSS to your dropdown content to define a custom width.
Expand Down
4 changes: 4 additions & 0 deletions src/auro-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Popover from "../lib/popover";
* @attr {boolean} toggle - If true, the trigger will toggle the show/hide state of the dropdown.
* @slot - Default unnamed slot for the use of popover content.
* @slot label - Sets the label text for the input.
* @slot helperText - Sets the helperText text for the input.
* @slot trigger - Slot for entering the trigger element into the scope of the shadow DOM.
*/
class AuroDropdown extends LitElement {
Expand Down Expand Up @@ -213,6 +214,9 @@ class AuroDropdown extends LitElement {
</div>
` : undefined}
</div>
<div class="helperText">
<slot name="helperText"></slot>
</div>
`;
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
}
}

:host([error]) {
.helperText {
color: var(--auro-color-text-error-on-light);
}
}

:host([bordered][error]) {
#trigger {
border-color: var(--auro-color-border-error-on-light);
Expand Down Expand Up @@ -114,6 +120,13 @@
}
}

.helperText {
color: var(--auro-color-text-secondary-on-light);
font-size: var(--auro-text-body-size-xs);
line-height: var(--auro-text-body-size-default);
margin-top: 4px;
}

.popover{
display:inline-block;
border-style: solid;
Expand Down

0 comments on commit 91648dd

Please sign in to comment.