protos 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7b9c6eb83f7c89f66d1f625fd200b2f6595c098130e16da1fcb6b2e96dd59fe
4
- data.tar.gz: 07a7e91d1ef7041dba38b72eb412309d31cf6426ad1e3b157f6a83fab59a32dd
3
+ metadata.gz: 875e55f36d03988e78d0e6834e840094b089ee1e755c003b6483a07a503bfbf4
4
+ data.tar.gz: 6b0bdbfc22451928316c73dd931cdeebe3e47cf20c596b3d5318b3145f51b5bc
5
5
  SHA512:
6
- metadata.gz: 36fa9e7809d68b3d1227814cb7bb23fc44066813de58360486f5c7ffffafb30f58f6cb50309aef8902796ea234dfe3f5dcd46b451673cf77600da5f257840e33
7
- data.tar.gz: 8ee74d55eebfaaec0d488809563695bf456229ed8dad466a10b6b5f20c117ed02644ef2a7a9646679a47697cae06eca5e6e50f21a863292d46c9753be4c82939
6
+ metadata.gz: 62c59568bcf8631d3d9c40de57ddb6b1df2f92183c0e9aa92e8be6b0da7d6e325e440a869eda3f1fd0cb93f651f9db8598a9914cc89b6454a1cda7f5a04517fc
7
+ data.tar.gz: 2ef45fba8e402133e4345fa91186713dc864e11d737bf3200548340cf7ed3d115e08b406b6d5c98eab8d568d4178b37d1b5e43fa13569dcc873fda6a8f338be9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.0] - 2024-08-27
4
+
5
+ - Fixes all accessibility violations according to Axe Core
6
+ - Reduces responsibility of Tabs to only be a tablist, no tab panels
7
+ - Fixes passing ID to popovers, dropdowns, drawers, etc to not override the
8
+ input ID
9
+ - Changes trigger on popover to be a button instead of a div
10
+
3
11
  ## [0.4.3] - 2024-08-14
4
12
 
5
13
  - Removes unneeded auto-loading in Rails which fixes collisions with `protos-markdown`
@@ -5,16 +5,16 @@ module Protos
5
5
  class Item < Component
6
6
  # DOCS: An accorion is just a collapse with radio buttons.
7
7
 
8
- option :id, type: Types::Coercible::String
8
+ option :input_id, type: Types::String | Types::Integer
9
9
 
10
10
  def view_template(&block)
11
11
  li(**attrs) do
12
- render Collapse.new(theme: collapse_theme) do
13
- # form: "" prevents the radio button from being submitted if its
14
- # within a form
15
- input(type: :radio, name: id, form: "", autocomplete: :off)
16
- yield if block
17
- end
12
+ render Collapse.new(
13
+ theme: collapse_theme,
14
+ input_id: @input_id.to_s,
15
+ input_type: :radio,
16
+ &block
17
+ )
18
18
  end
19
19
  end
20
20
 
@@ -7,20 +7,30 @@ module Protos
7
7
  # to be open at the same time, use the collapse component.
8
8
  # https://daisyui.com/components/accordion/
9
9
 
10
- option :id, default: -> { "collapse-#{SecureRandom.hex(4)}" }
11
-
12
10
  def view_template(&)
13
11
  ul(**attrs, &)
14
12
  end
15
13
 
16
- def item(*, **, &) = render Item.new(*, id:, **, &)
14
+ def item(*, input_id: nil, **, &)
15
+ self.current_input_id = input_id
16
+
17
+ render Item.new(*, input_id: current_input_id, **, &)
18
+ end
17
19
 
18
20
  def content(...) = render Collapse::Content.new(...)
19
21
 
20
- def title(*, **, &) = render Collapse::Title.new(*, id:, **, &)
22
+ def title(*, **, &)
23
+ render Collapse::Title.new(*, input_id: current_input_id, **, &)
24
+ end
21
25
 
22
26
  private
23
27
 
28
+ attr_reader :current_input_id
29
+
30
+ def current_input_id=(value)
31
+ @current_input_id = value || "collapse-#{SecureRandom.hex(4)}"
32
+ end
33
+
24
34
  def theme
25
35
  {
26
36
  container: "join join-vertical"
@@ -11,6 +11,12 @@ module Protos
11
11
 
12
12
  private
13
13
 
14
+ def default_attrs
15
+ {
16
+ aria_label: "alert-actions"
17
+ }
18
+ end
19
+
14
20
  def theme
15
21
  {
16
22
  container: "flex gap-xs items-center"
@@ -15,6 +15,12 @@ module Protos
15
15
 
16
16
  private
17
17
 
18
+ def default_attrs
19
+ {
20
+ aria_label: "breadcrumbs"
21
+ }
22
+ end
23
+
18
24
  def theme
19
25
  {
20
26
  container: "breadcrumbs"
@@ -5,14 +5,15 @@ module Protos
5
5
  class Title < Component
6
6
  # DOCS: The title of a collapse. This is the content that is always
7
7
  # visible and is used to toggle the collapse.
8
- option :id,
9
- type: Types::Coercible::String,
8
+
9
+ option :input_id,
10
+ type: Types::String | Types::Integer | Types::Nil,
10
11
  reader: false,
11
- default: -> { "" }
12
+ default: -> { }
12
13
 
13
14
  def view_template(&)
14
- if @id.size.positive?
15
- label(for: @id, **attrs, &)
15
+ if @input_id
16
+ label(for: @input_id.to_s, **attrs, &)
16
17
  else
17
18
  div(**attrs, &)
18
19
  end
@@ -6,19 +6,30 @@ module Protos
6
6
  # is visible at all times, and the content is only visible when expanded.
7
7
  # https://daisyui.com/components/collapse/
8
8
 
9
- option :checkbox, default: -> { false }, type: Types::Bool, reader: false
10
- option :id,
9
+ option :input_type, default: -> { :checkbox }, reader: false
10
+ option :input_id,
11
+ reader: false,
11
12
  default: -> { "collapse-#{SecureRandom.hex(4)}" },
12
13
  type: Types::String
13
14
 
14
15
  def view_template
15
16
  div(**attrs) do
16
- input(type: "checkbox", id:, autocomplete: :off) if @checkbox
17
+ if @input_type
18
+ input(
19
+ type: @input_type,
20
+ id: @input_id,
21
+ name: @input_id,
22
+ autocomplete: :off,
23
+ # form: "" prevents the radio button from being submitted if its
24
+ # within a form
25
+ form: ""
26
+ )
27
+ end
17
28
  yield if block_given?
18
29
  end
19
30
  end
20
31
 
21
- def title(*, **, &) = render Title.new(*, id:, **, &)
32
+ def title(*, **, &) = render Title.new(*, input_id: @input_id, **, &)
22
33
 
23
34
  def content(...) = render Content.new(...)
24
35
 
@@ -12,7 +12,7 @@ module Protos
12
12
  }
13
13
 
14
14
  def view_template(&block)
15
- div(**attrs) do
15
+ li(**attrs) do
16
16
  label(class: css[:label]) do
17
17
  div(class: css[:icon], &block) if block
18
18
  input(
@@ -7,7 +7,7 @@ module Protos
7
7
  # inside a Protos::Command::Group component.
8
8
 
9
9
  def view_template(&)
10
- h2(**attrs, &)
10
+ li { h2(**attrs, &) }
11
11
  end
12
12
 
13
13
  private
@@ -6,11 +6,15 @@ module Protos
6
6
  # DOCS: The content that will be shown when you open the drawer using the
7
7
  # trigger. This would be hidden until triggered.
8
8
 
9
- option :id, type: Types::Coercible::String
9
+ option :input_id, reader: false, type: Types::String
10
10
 
11
11
  def view_template
12
12
  aside(**attrs) do
13
- label(for: id, aria_label: "close sidebar", class: css[:toggle])
13
+ label(
14
+ for: @input_id,
15
+ aria_label: "close sidebar",
16
+ class: css[:toggle]
17
+ )
14
18
  yield if block_given?
15
19
  end
16
20
  end
@@ -6,10 +6,10 @@ module Protos
6
6
  # DOCS: The trigger for a drawer. When this is clicked the side will open
7
7
  # and overlap the main content with a darker overlay.
8
8
 
9
- option :id, type: Types::Coercible::String
9
+ option :input_id, reader: false, type: Types::String
10
10
 
11
11
  def view_template(&)
12
- label(for: id, **attrs, &)
12
+ label(for: @input_id, **attrs, &)
13
13
  end
14
14
 
15
15
  private
data/lib/protos/drawer.rb CHANGED
@@ -7,20 +7,29 @@ module Protos
7
7
  # trigger is clicked.
8
8
  # https://daisyui.com/components/drawer/
9
9
 
10
- option :id, type: Types::Coercible::String
10
+ option :id,
11
+ reader: false,
12
+ type: Types::Coercible::String,
13
+ default: -> { "drawer-#{SecureRandom.hex(4)}" }
11
14
 
12
15
  def view_template
13
16
  div(**attrs) do
14
- input(id:, type: :checkbox, class: css[:toggle], autocomplete: :off)
17
+ input(
18
+ id: @id,
19
+ type: :checkbox,
20
+ class: css[:toggle],
21
+ autocomplete: :off,
22
+ form: ""
23
+ )
15
24
  yield if block_given?
16
25
  end
17
26
  end
18
27
 
19
28
  def content(...) = render Content.new(...)
20
29
 
21
- def side(*, **, &) = render Side.new(*, id:, **, &)
30
+ def side(*, **, &) = render Side.new(*, input_id: @id, **, &)
22
31
 
23
- def trigger(*, **, &) = render Trigger.new(*, id:, **, &)
32
+ def trigger(*, **, &) = render Trigger.new(*, input_id: @id, **, &)
24
33
 
25
34
  private
26
35
 
@@ -7,7 +7,7 @@ module Protos
7
7
  # or click on to show the popover.
8
8
 
9
9
  def view_template(&)
10
- div(**attrs, &)
10
+ button(**attrs, &)
11
11
  end
12
12
 
13
13
  private
@@ -15,7 +15,8 @@ module Protos
15
15
  def default_attrs
16
16
  {
17
17
  data: { "protos--popover-target": "trigger" },
18
- tabindex: 0
18
+ tabindex: 0,
19
+ type: :button
19
20
  }
20
21
  end
21
22
  end
data/lib/protos/swap.rb CHANGED
@@ -8,7 +8,13 @@ module Protos
8
8
 
9
9
  def view_template
10
10
  label(**attrs) do
11
- input(type: :checkbox, class: css[:input], autocomplete: :off)
11
+ input(
12
+ type: :checkbox,
13
+ class: css[:input],
14
+ autocomplete: :off,
15
+ form: "",
16
+ aria_label: "swap"
17
+ )
12
18
  yield if block_given?
13
19
  end
14
20
  end
@@ -5,35 +5,24 @@ module Protos
5
5
  class Tab < Component
6
6
  # DOCS: A single tab in a tabs component
7
7
 
8
- option :id
9
- option :label
10
8
  option :active, default: -> { false }
11
9
  option :disabled, default: -> { false }
12
10
 
13
11
  def view_template(&)
14
- input(
15
- type: :radio,
16
- class: css[:input],
17
- name: id,
18
- role: :tab,
19
- aria_label: label,
20
- autocomplete: :off
21
- )
22
- div(**attrs, &)
12
+ button(**attrs, disabled:, &)
23
13
  end
24
14
 
25
15
  private
26
16
 
27
17
  def default_attrs
28
18
  {
29
- role: :tabpanel
19
+ role: :tab
30
20
  }
31
21
  end
32
22
 
33
23
  def theme
34
24
  {
35
- container: "tab-content",
36
- input: tokens(
25
+ container: tokens(
37
26
  "tab",
38
27
  disabled: "tab-disabled",
39
28
  active: "tab-active"
@@ -8,6 +8,7 @@ module Protos
8
8
  def view_template(&block)
9
9
  form(method: :dialog, class: css[:form]) do
10
10
  button(
11
+ aria_label: "close",
11
12
  autofocus: true,
12
13
  formmethod: :dialog,
13
14
  formnovalidate: true,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Protos
4
- VERSION = "0.4.3"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nolan J Tait
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-15 00:00:00.000000000 Z
11
+ date: 2024-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-core
@@ -220,7 +220,7 @@ requirements:
220
220
  - tailwindcss
221
221
  - daisyui
222
222
  - protos-stimulus
223
- rubygems_version: 3.5.17
223
+ rubygems_version: 3.5.18
224
224
  signing_key:
225
225
  specification_version: 4
226
226
  summary: A UI component library built with phlex and daisyui