Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add labels and hint blocks to fields #110

Merged
merged 25 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
592be1f
feat: Adding label and hint blocks to field components
nicolechung Mar 27, 2023
6be3034
docs: Label and hint blocks, update demos
nicolechung Mar 27, 2023
9561e19
fix: FieldSet, roll back label and hint
nicolechung Mar 27, 2023
28cdac4
feat: CheckboxGroupField, RadioGroupField, yield label and hint blocks
nicolechung Mar 29, 2023
e7908b2
docs: CheckboxGroupField, RadioGroupField
nicolechung Mar 29, 2023
66e052e
docs: FileInputField, add headers for each UI State
nicolechung Mar 29, 2023
d124220
fix: CheckboxGroupField, remove aria-invalid test
nicolechung Mar 29, 2023
a43ebd9
docs: CheckboxField Base Demo, fix closing tag issues
nicolechung Mar 29, 2023
edcbcfc
docs: Fixes to merge conflicts
nicolechung Mar 31, 2023
5696ebb
fix: Rename tests to start with Field
nicolechung Mar 31, 2023
45a6e2d
fix: Field components, add test for label and hint blocks
nicolechung Mar 31, 2023
9f3d234
feat: Field components, make consumer choose arg or block
nicolechung Apr 4, 2023
b26a771
docs: Update docs with @label/:label and @hint/:hint
nicolechung Apr 4, 2023
3635599
feat: Add non-standard helpers for checking args and blocks
nicolechung Apr 5, 2023
eb9c5c3
feat: Add helpers to the field component backing classes
nicolechung Apr 5, 2023
52ace63
feat: use helpers in field templates
nicolechung Apr 5, 2023
e800b56
test: Update tests with new assertions
nicolechung Apr 5, 2023
9e69290
fix: Remove helpers, consolidate into assert-block-or-arg-exists
nicolechung Apr 5, 2023
27e67ab
fix: Adjust all Field components to use the new single helper
nicolechung Apr 5, 2023
238f63d
fix: Remove @label in a field that uses a :label block
nicolechung Apr 5, 2023
11b3449
docs: Fixes to Field components
nicolechung Apr 6, 2023
a8ac90a
fix: Field component, test messages
nicolechung Apr 6, 2023
1e0f2fe
fix: Remove extra line space in radio field component
nicolechung Apr 6, 2023
afb5183
fix: Fieldset, removed component and related files
nicolechung Apr 11, 2023
26b324f
Added Changeset for label and hint blocks in the Field components
nicolechung Apr 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/famous-foxes-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@crowdstrike/ember-toucan-core': minor
---

- Added label and hint named blocks to all the Field components.
- Removed Fieldset.
72 changes: 69 additions & 3 deletions docs/components/checkbox-field/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,71 @@ Provides an underlying checkbox element building on top of the Field component.

## Label

Provide a string to `@label` to render the text into the `<label>` of the Field.
Required.

Use either the `@label` component argument or the `:label` named block.

Provide a string to the `@label` component argument or content to the `:label` named block to render into the Label section.

### @label

```hbs template
<Form::Fields::Checkbox
@label='Label here'
@name='options'
@value={{this.groupValue}}
@onChange={{this.updateValue}}
/>
```

### :label

```hbs template
<Form::Fields::Checkbox
@name='options'
@value={{this.groupValue}}
@onChange={{this.updateValue}}
>
<:label>Here is a label <IconButton><Tooltip /><IconButton></:label>
</Form::Fields::Checkbox>
```

## Hint

Optional. Provide a string to `@hint` to render the text into the Hint section of the Field.
Optional.

Use either the `@hint` component argument or the `:hint` named block.

Provide a string to the `@hint` component argument or content to `:hint` named block to render into the Hint section.

### @hint

```hbs template
<Form::Fields::Checkbox
@hint='Here is a hint'
@name='options'
@value={{this.groupValue}}
@onChange={{this.updateValue}}
/>
```

### :hint

```hbs template
<Form::Fields::Checkbox
@name='options'
@value={{this.groupValue}}
@onChange={{this.updateValue}}
>
<:hint>Here is a hint <Link to='somewhere'>Link</Link></:hint>
</Form::Fields::Checkbox>
```

## Error

Optional. Provide a string or array of strings to `@error` to render the text into the Error section of the Field.
Optional.

Provide a string or array of strings to `@error` to render the text into the Error section of the Field.

```hbs
<Form::Fields::Checkbox @label='Single error' @error='Error' />
Expand Down Expand Up @@ -139,6 +195,16 @@ Target the error block via `data-error`.
/>
</div>

### CheckboxField with label and hint blocks

<div class='mb-4 w-64'>
<Form::Fields::Checkbox
>
<:label>Label <svg class="inline" xmlns="http://www.w3.org/2000/svg" width="24" height="24" stroke="currentColor" viewBox="0 0 24 24"><path d="M12 3a9 9 0 11-6.364 2.636A8.972 8.972 0 0112 3zm0 4.7v5.2m0 3.39v.01" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg></:label>
<:hint>Select <a href="https://www.crowdstrike.com/">link</a></:hint>
</Form::Fields::Checkbox>
</div>

### CheckboxField with label and isDisabled

<div class='mb-4 w-64'>
Expand Down
80 changes: 78 additions & 2 deletions docs/components/checkbox-group-field/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,73 @@ Provides a checkbox group to be used within forms. It yields [CheckboxFields](./

## Label

Provide a string to `@label` to render the text into the `<legend>` of the fieldset.
Required.

Use either the `@label` component argument or the `:label` named block.

Provide a string to the `@label` component argument or content to the `:label` named block to render into the legend of the fieldset.

### @label

```hbs template
<Form::Fields::CheckboxGroup
@label='Label here'
@name='options'
@value={{this.groupValue}}
@onChange={{this.updateValue}}
/>
```

### :label

```hbs template
<Form::Fields::CheckboxGroup
@name='options'
@value={{this.groupValue}}
@onChange={{this.updateValue}}
>
{{!-- default block is required here when using :label --}}
<:default as |group|>
{{!-- render checkboxes here --}}
</:default>
<:label>Here is a label <IconButton><Tooltip /><IconButton></:label>
</Form::Fields::CheckboxGroup>
```

## Hint

Optional. Provide a string to `@hint` to render the text into the Hint section of the fieldset.
Optional.

Use either the `@hint` component argument or the `:hint` named block.

Provide a string to the `@hint` component argument or content to `:hint` named block to render into the Hint section.

### @hint

```hbs template
<Form::Fields::CheckboxGroup
@hint='Here is a hint'
@name='options'
@value={{this.groupValue}}
@onChange={{this.updateValue}}
/>
```

### :hint

```hbs template
<Form::Fields::CheckboxGroup
@name='options'
@value={{this.groupValue}}
@onChange={{this.updateValue}}
>
{{! default block is required here when using :hint}}
<:default as |group|>
{{! render checkboxes here }}
</:default>
<:hint>Here is a hint <Link to='somewhere'>Link</Link></:hint>
</Form::Fields::CheckboxGroup>
```

## Error

Expand Down Expand Up @@ -126,6 +188,20 @@ Consumers have direct access to the underlying [checkbox element](https://develo
</Form::Fields::CheckboxGroup>
</div>

### CheckboxGroupField with label block and hint block

<div class='mb-4 w-64'>
<Form::Fields::CheckboxGroup @name='options-b'>
<:default as |group|>
<group.CheckboxField @label='Option 1' @value='option-1' />
<group.CheckboxField @label='Option 2' @value='option-2' />
<group.CheckboxField @label='Option 3' @value='option-3' />
</:default>
<:label>Label <svg class="inline" xmlns="http://www.w3.org/2000/svg" width="24" height="24" stroke="currentColor" viewBox="0 0 24 24"><path d="M12 3a9 9 0 11-6.364 2.636A8.972 8.972 0 0112 3zm0 4.7v5.2m0 3.39v.01" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg></:label>
<:hint>Select an option <a href="https://www.crowdstrike.com/">link</a></:hint>
</Form::Fields::CheckboxGroup>
</div>

### CheckboxGroupField with label and error

<div class='mb-4 w-64'>
Expand Down
16 changes: 0 additions & 16 deletions docs/components/fieldset/demo/base-demo.md

This file was deleted.

105 changes: 0 additions & 105 deletions docs/components/fieldset/index.md

This file was deleted.

Loading