ariadne_view_components 0.0.93.1 → 0.0.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +13 -4
- data/app/assets/javascripts/ariadne_view_components.js +14 -14
- data/app/assets/javascripts/ariadne_view_components.js.br +0 -0
- data/app/assets/javascripts/ariadne_view_components.js.gz +0 -0
- data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
- data/app/assets/stylesheets/ariadne_view_components.css +1 -1
- data/app/assets/stylesheets/ariadne_view_components.css.br +0 -0
- data/app/assets/stylesheets/ariadne_view_components.css.gz +0 -0
- data/app/components/ariadne/base_component.rb +25 -22
- data/app/components/ariadne/behaviors/tooltipable.rb +12 -12
- data/app/components/ariadne/form/checkbox/component.rb +2 -2
- data/app/components/ariadne/form/group/component.rb +1 -1
- data/app/components/ariadne/form/radio_button/component.rb +2 -2
- data/app/components/ariadne/form/select/component.rb +1 -1
- data/app/components/ariadne/form/text_field/component.html.erb +2 -2
- data/app/components/ariadne/form/text_field/component.rb +14 -7
- data/app/components/ariadne/form/toggle/component.rb +2 -2
- data/app/components/ariadne/form/toggle_group/component.rb +1 -1
- data/app/components/ariadne/form/toggle_group/option/component.rb +1 -1
- data/app/components/ariadne/layout/grid/component.rb +1 -1
- data/app/components/ariadne/layout/grid/item/component.rb +2 -2
- data/app/components/ariadne/layout/label_block/component.rb +1 -1
- data/app/components/ariadne/layout/narrow/component.rb +1 -1
- data/app/components/ariadne/ui/accordion/component.rb +3 -1
- data/app/components/ariadne/ui/accordion/item/component.html.erb +10 -10
- data/app/components/ariadne/ui/accordion/item/component.rb +12 -3
- data/app/components/ariadne/ui/avatar/component.html.erb +9 -7
- data/app/components/ariadne/ui/avatar/component.rb +55 -7
- data/app/components/ariadne/ui/badge/component.rb +35 -16
- data/app/components/ariadne/ui/banner/component.html.erb +23 -0
- data/app/components/ariadne/ui/banner/component.rb +226 -0
- data/app/components/ariadne/ui/banner/component.ts +46 -0
- data/app/components/ariadne/ui/blankslate/component.html.erb +2 -2
- data/app/components/ariadne/ui/blankslate/component.rb +12 -1
- data/app/components/ariadne/ui/button/component.rb +35 -24
- data/app/components/ariadne/ui/card/body/component.rb +1 -1
- data/app/components/ariadne/ui/card/component.rb +11 -7
- data/app/components/ariadne/ui/card/footer/component.rb +1 -1
- data/app/components/ariadne/ui/card/header/component.html.erb +2 -2
- data/app/components/ariadne/ui/card/header/component.rb +25 -16
- data/app/components/ariadne/ui/clipboard_copy/component.html.erb +1 -0
- data/app/components/ariadne/ui/clipboard_copy/component.rb +17 -21
- data/app/components/ariadne/ui/clipboard_copy/component.ts +15 -0
- data/app/components/ariadne/ui/color_dot/component.html.erb +5 -5
- data/app/components/ariadne/ui/color_dot/component.rb +19 -4
- data/app/components/ariadne/ui/combobox/component.html.erb +1 -1
- data/app/components/ariadne/ui/combobox/component.rb +54 -23
- data/app/components/ariadne/ui/combobox/component.ts +2 -0
- data/app/components/ariadne/ui/dialog/body/component.html.erb +3 -0
- data/app/components/ariadne/ui/dialog/body/component.rb +28 -0
- data/app/components/ariadne/ui/dialog/component.html.erb +25 -24
- data/app/components/ariadne/ui/dialog/component.rb +87 -18
- data/app/components/ariadne/ui/dialog/component.ts +5 -1
- data/app/components/ariadne/ui/dialog/footer/component.html.erb +3 -0
- data/app/components/ariadne/ui/dialog/footer/component.rb +34 -0
- data/app/components/ariadne/ui/heroicon/component.rb +21 -21
- data/app/components/ariadne/ui/image/component.rb +11 -23
- data/app/components/ariadne/ui/link/component.html.erb +1 -3
- data/app/components/ariadne/ui/link/component.rb +17 -4
- data/app/components/ariadne/ui/list/component.html.erb +5 -9
- data/app/components/ariadne/ui/list/component.rb +31 -7
- data/app/components/ariadne/ui/list/item/component.rb +6 -5
- data/app/components/ariadne/ui/pagination/component.rb +1 -2
- data/app/components/ariadne/ui/popover/component.html.erb +1 -1
- data/app/components/ariadne/ui/popover/component.rb +31 -26
- data/app/components/ariadne/ui/relative_time/component.html.erb +1 -0
- data/app/components/ariadne/ui/{time_ago → relative_time}/component.rb +15 -15
- data/app/components/ariadne/ui/{time_ago → relative_time}/component.ts +1 -1
- data/app/components/ariadne/ui/shortcut/component.html.erb +0 -1
- data/app/components/ariadne/ui/shortcut/component.rb +31 -5
- data/app/components/ariadne/ui/shortcut/component.ts +1 -1
- data/app/components/ariadne/ui/skeleton/component.rb +2 -8
- data/app/components/ariadne/ui/stats_panel/component.html.erb +3 -3
- data/app/components/ariadne/ui/stats_panel/component.rb +25 -1
- data/app/components/ariadne/ui/stats_panel/item/component.html.erb +3 -3
- data/app/components/ariadne/ui/stats_panel/item/component.rb +6 -6
- data/app/components/ariadne/ui/table/cell/component.rb +1 -1
- data/app/components/ariadne/ui/table/row/component.rb +1 -1
- data/app/components/ariadne/ui/typography/component.rb +3 -1
- data/app/frontend/controllers/tooltip_controller.ts +8 -3
- data/app/frontend/stylesheets/ariadne_view_components.css +1 -0
- data/app/frontend/stylesheets/theme.css +88 -0
- data/app/frontend/utils/createController.ts +9 -0
- data/app/helpers/ariadne/color_helper.rb +158 -0
- data/app/helpers/ariadne/form_helper.rb +1 -0
- data/app/helpers/ariadne/size_helper.rb +7 -0
- data/app/lib/ariadne/attributes_helper.rb +4 -4
- data/app/lib/ariadne/view_component/style_variants.rb +1 -1
- data/app/lib/ariadne/view_helper.rb +0 -6
- data/lib/ariadne/accessibility.rb +64 -0
- data/lib/ariadne/forms/dsl/form_object.rb +5 -1
- data/lib/ariadne/forms/dsl/input.rb +1 -1
- data/lib/ariadne/static/generate_arguments.rb +54 -0
- data/lib/ariadne/static/generate_audited_at.rb +17 -0
- data/lib/ariadne/static/generate_constants.rb +19 -0
- data/lib/ariadne/static/generate_previews.rb +53 -0
- data/lib/ariadne/static/generate_statuses.rb +17 -0
- data/lib/ariadne/static/generate_structure.rb +279 -0
- data/lib/ariadne/static.rb +68 -0
- data/lib/ariadne/view_components/constants.rb +2 -2
- data/lib/ariadne/view_components/version.rb +1 -1
- data/lib/ariadne/view_components.rb +0 -51
- data/lib/ariadne/yard/component_manifest.rb +81 -81
- data/lib/ariadne/yard/component_ref.rb +1 -1
- data/lib/ariadne/yard/docs_helper.rb +24 -16
- data/lib/ariadne/yard/dry_initializer/common_handler.rb +103 -0
- data/lib/ariadne/yard/dry_initializer/option_handler.rb +38 -0
- data/lib/ariadne/yard/dry_initializer/param_handler.rb +57 -0
- data/lib/ariadne/yard/registry.rb +2 -5
- data/lib/ariadne/yard/{info_arch_docs_helper.rb → structure_docs_helper.rb} +5 -5
- data/lib/ariadne/yard.rb +20 -8
- data/lib/rubocop/config/default.yml +0 -3
- metadata +34 -37
- data/app/components/ariadne/behaviors/captionable.rb +0 -55
- data/app/components/ariadne/turbo/frame/component.html.erb +0 -3
- data/app/components/ariadne/turbo/frame/component.rb +0 -16
- data/app/components/ariadne/turbo/stream_action/component.html.erb +0 -4
- data/app/components/ariadne/turbo/stream_action/component.rb +0 -25
- data/app/components/ariadne/ui/data_table/component.html.erb +0 -1
- data/app/components/ariadne/ui/data_table/component.rb +0 -11
- data/app/components/ariadne/ui/flash/component.html.erb +0 -18
- data/app/components/ariadne/ui/flash/component.rb +0 -151
- data/app/components/ariadne/ui/flash/component.ts +0 -56
- data/app/components/ariadne/ui/overlay/component.html.erb +0 -12
- data/app/components/ariadne/ui/overlay/component.rb +0 -54
- data/app/components/ariadne/ui/overlay/component.ts +0 -92
- data/app/components/ariadne/ui/time_ago/component.html.erb +0 -1
- data/lib/ariadne/view_components/commands.rb +0 -90
- data/lib/ariadne/view_components/statuses.rb +0 -14
- data/lib/ariadne/view_components/upstream.rb +0 -19
- data/lib/ariadne/yard/lookbook_pages_backend.rb +0 -235
- data/lib/rubocop/cop/ariadne/no_tag_memoize.rb +0 -44
- data/static/arguments.yml +0 -879
- data/static/assets/view-components.svg +0 -18
- data/static/classes.yml +0 -211
- data/static/constants.json +0 -743
- data/static/statuses.json +0 -58
- data/static/tailwindcss.yml +0 -727
- /data/app/components/ariadne/ui/{time_ago → relative_time}/en.yml +0 -0
| @@ -13,10 +13,10 @@ | |
| 13 13 | 
             
                input? ? :input : :textarea,
         | 
| 14 14 | 
             
                input? ? nil : html_attrs[:value],
         | 
| 15 15 | 
             
                name: @name,
         | 
| 16 | 
            -
                class:  | 
| 16 | 
            +
                class: merge_tailwind_classes([html_attrs[:class], style(with_leading_item: leading_visual ? :yes : :no)]),
         | 
| 17 17 | 
             
                type: @type,
         | 
| 18 18 | 
             
                **html_attrs.except(:class)
         | 
| 19 | 
            -
             | 
| 19 | 
            +
                ) %>
         | 
| 20 20 | 
             
                <% if @validation_message %>
         | 
| 21 21 | 
             
                  <%= render(Primer::BaseComponent.new(tag: :div, **@validation_arguments)) do %>
         | 
| 22 22 | 
             
                    <span class="FormControl-inlineValidation--visual"><%= render(Primer::Beta::Octicon.new(icon: :"alert-fill", size: :xsmall, aria: { hidden: true })) %></span>
         | 
| @@ -3,6 +3,14 @@ | |
| 3 3 | 
             
            module Ariadne
         | 
| 4 4 | 
             
              module Form
         | 
| 5 5 | 
             
                module TextField
         | 
| 6 | 
            +
                  # Text fields are single-line text inputs rendered as `<input type="text">` in HTML.
         | 
| 7 | 
            +
                  #
         | 
| 8 | 
            +
                  # @form_usage
         | 
| 9 | 
            +
                  #   class ExampleForm < ApplicationForm
         | 
| 10 | 
            +
                  #     form do |example_form|
         | 
| 11 | 
            +
                  #       example_form.text_field(attributes)
         | 
| 12 | 
            +
                  #     end
         | 
| 13 | 
            +
                  #   end
         | 
| 6 14 | 
             
                  class Component < Ariadne::Form::BaseInputComponent
         | 
| 7 15 | 
             
                    option :name
         | 
| 8 16 | 
             
                    option :label
         | 
| @@ -16,15 +24,15 @@ module Ariadne | |
| 16 24 | 
             
                    }
         | 
| 17 25 | 
             
                    # renders_one :trailing_visual, BaseComponent::ACCEPT_ANYTHING
         | 
| 18 26 |  | 
| 19 | 
            -
                    option :theme, default:  | 
| 20 | 
            -
                    option :size, default:  | 
| 21 | 
            -
                    option :width, default:  | 
| 27 | 
            +
                    option :theme, default: -> { :primary }
         | 
| 28 | 
            +
                    option :size, default: -> { :base }
         | 
| 29 | 
            +
                    option :width, default: -> { :narrow }
         | 
| 22 30 |  | 
| 23 31 | 
             
                    option :label_classes, default: -> { "" }
         | 
| 24 32 | 
             
                    option :label_arguments, default: -> { {} }
         | 
| 25 33 |  | 
| 26 34 | 
             
                    accepts_html_attributes do |html_attrs|
         | 
| 27 | 
            -
                      html_attrs[:class] =  | 
| 35 | 
            +
                      html_attrs[:class] = merge_tailwind_classes([style(theme:, size:, width:), html_attrs[:class]].join(" "))
         | 
| 28 36 |  | 
| 29 37 | 
             
                      html_attrs
         | 
| 30 38 | 
             
                    end
         | 
| @@ -38,7 +46,7 @@ module Ariadne | |
| 38 46 | 
             
                    end
         | 
| 39 47 |  | 
| 40 48 | 
             
                    def label_styles
         | 
| 41 | 
            -
                       | 
| 49 | 
            +
                      merge_tailwind_classes([style(:label), label_classes].join(" "))
         | 
| 42 50 | 
             
                    end
         | 
| 43 51 |  | 
| 44 52 | 
             
                    style do
         | 
| @@ -53,9 +61,8 @@ module Ariadne | |
| 53 61 | 
             
                          "dark:disabled:ariadne-text-zinc-600",
         | 
| 54 62 | 
             
                          "disabled:ariadne-cursor-not-allowed",
         | 
| 55 63 |  | 
| 56 | 
            -
                          "ariadne-bg- | 
| 64 | 
            +
                          "ariadne-bg-slate-50",
         | 
| 57 65 | 
             
                          "dark:ariadne-bg-foreground-dark",
         | 
| 58 | 
            -
                          "dark:ariadne-bg-zinc-900",
         | 
| 59 66 | 
             
                        ]
         | 
| 60 67 | 
             
                      end
         | 
| 61 68 |  | 
| @@ -22,7 +22,7 @@ module Ariadne | |
| 22 22 | 
             
                    option :enabled, default: proc { true }
         | 
| 23 23 |  | 
| 24 24 | 
             
                    accepts_html_attributes do |html_attrs|
         | 
| 25 | 
            -
                      html_attrs[:class] =  | 
| 25 | 
            +
                      html_attrs[:class] = merge_tailwind_classes(["ariadne-sr-only ariadne-peer", html_attrs[:class]].join(" "))
         | 
| 26 26 |  | 
| 27 27 | 
             
                      if @checked
         | 
| 28 28 | 
             
                        html_attrs[:checked] = @checked
         | 
| @@ -40,7 +40,7 @@ module Ariadne | |
| 40 40 | 
             
                    end
         | 
| 41 41 |  | 
| 42 42 | 
             
                    def before_render
         | 
| 43 | 
            -
                      @label_id =  | 
| 43 | 
            +
                      @label_id = Ariadne::BaseComponent.generate_id
         | 
| 44 44 |  | 
| 45 45 | 
             
                      if @form_url.present?
         | 
| 46 46 | 
             
                        csrf_token = view_context.form_authenticity_token(
         | 
| @@ -12,7 +12,7 @@ module Ariadne | |
| 12 12 | 
             
                    }
         | 
| 13 13 |  | 
| 14 14 | 
             
                    accepts_html_attributes do |html_attrs|
         | 
| 15 | 
            -
                      html_attrs[:class] =  | 
| 15 | 
            +
                      html_attrs[:class] = merge_tailwind_classes([style, html_attrs[:class]].join(" "))
         | 
| 16 16 | 
             
                    end
         | 
| 17 17 |  | 
| 18 18 | 
             
                    style do
         | 
| @@ -13,7 +13,7 @@ module Ariadne | |
| 13 13 | 
             
                      option :checked, default: proc { false }
         | 
| 14 14 |  | 
| 15 15 | 
             
                      accepts_html_attributes do |html_attrs|
         | 
| 16 | 
            -
                        html_attrs[:class] =  | 
| 16 | 
            +
                        html_attrs[:class] = merge_tailwind_classes([style(:tab), html_attrs[:class]].join(" "))
         | 
| 17 17 | 
             
                      end
         | 
| 18 18 |  | 
| 19 19 | 
             
                      def input_type
         | 
| @@ -8,7 +8,7 @@ module Ariadne | |
| 8 8 | 
             
                    renders_many :items, Ariadne::Layout::Grid::Item::Component
         | 
| 9 9 |  | 
| 10 10 | 
             
                    accepts_html_attributes do |html_attrs|
         | 
| 11 | 
            -
                      html_attrs[:class] =  | 
| 11 | 
            +
                      html_attrs[:class] = merge_tailwind_classes([style(:grid), html_attrs[:class]].join(" "))
         | 
| 12 12 | 
             
                    end
         | 
| 13 13 |  | 
| 14 14 | 
             
                    style :grid do
         | 
| @@ -6,10 +6,10 @@ module Ariadne | |
| 6 6 | 
             
                module Grid
         | 
| 7 7 | 
             
                  module Item
         | 
| 8 8 | 
             
                    class Component < Ariadne::BaseComponent
         | 
| 9 | 
            -
                      option :type, default:  | 
| 9 | 
            +
                      option :type, default: -> { :base }
         | 
| 10 10 |  | 
| 11 11 | 
             
                      accepts_html_attributes do |html_attrs|
         | 
| 12 | 
            -
                        html_attrs[:class] =  | 
| 12 | 
            +
                        html_attrs[:class] = merge_tailwind_classes([style(:item), html_attrs[:class]].join(" "))
         | 
| 13 13 | 
             
                      end
         | 
| 14 14 |  | 
| 15 15 | 
             
                      def blank?
         | 
| @@ -21,7 +21,7 @@ module Ariadne | |
| 21 21 | 
             
                        options[:theme] ||= :none
         | 
| 22 22 | 
             
                        options[:html_attrs] ||= {}
         | 
| 23 23 |  | 
| 24 | 
            -
                        options[:html_attrs][:class] =  | 
| 24 | 
            +
                        options[:html_attrs][:class] = merge_tailwind_classes([style(:trailing_visual), options[:html_attrs][:class] || ""].join(" "))
         | 
| 25 25 |  | 
| 26 26 | 
             
                        Ariadne::UI::Button::Component.new(**options)
         | 
| 27 27 | 
             
                      },
         | 
| @@ -8,7 +8,7 @@ module Ariadne | |
| 8 8 | 
             
                    renders_one :footer, Ariadne::BaseComponent::ACCEPT_ANYTHING
         | 
| 9 9 |  | 
| 10 10 | 
             
                    accepts_html_attributes do |html_attrs|
         | 
| 11 | 
            -
                      html_attrs[:class] =  | 
| 11 | 
            +
                      html_attrs[:class] = merge_tailwind_classes([style(:container), html_attrs[:class]].join(" "))
         | 
| 12 12 | 
             
                    end
         | 
| 13 13 |  | 
| 14 14 | 
             
                    style(:container) do
         | 
| @@ -4,11 +4,13 @@ | |
| 4 4 | 
             
            module Ariadne
         | 
| 5 5 | 
             
              module UI
         | 
| 6 6 | 
             
                module Accordion
         | 
| 7 | 
            +
                  # A vertically stacked set of interactive headings that each reveal a section of content.
         | 
| 7 8 | 
             
                  class Component < Ariadne::BaseComponent
         | 
| 9 | 
            +
                    # Represent the item stored within the accordion.
         | 
| 8 10 | 
             
                    renders_many :items, Ariadne::UI::Accordion::Item::Component
         | 
| 9 11 |  | 
| 10 12 | 
             
                    accepts_html_attributes do |html_attrs|
         | 
| 11 | 
            -
                      html_attrs[:class] =  | 
| 13 | 
            +
                      html_attrs[:class] = merge_tailwind_classes([style, html_attrs[:class]].join(" "))
         | 
| 12 14 | 
             
                    end
         | 
| 13 15 |  | 
| 14 16 | 
             
                    style do
         | 
| @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            <div class="<%= style(:item) %>" data-controller="<%= Ariadne::UI::Accordion::Component.stimulus_name %>">
         | 
| 2 | 
            -
              <button type="button" class="<%= html_attrs[:class] %>" <%= html_attributes  | 
| 2 | 
            +
              <button type="button" class="<%= html_attrs[:class] %>" <%= html_attributes %>>
         | 
| 3 3 | 
             
                <%= text %>
         | 
| 4 4 | 
             
                <div data-<%= Ariadne::UI::Accordion::Component.stimulus_name %>-target="icon">
         | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
                </div>
         | 
| 11 | 
            -
              </button>
         | 
| 12 | 
            -
              <div class="<%= style(:content) %>" data-<%= Ariadne::UI::Accordion::Component.stimulus_name %>-target="content">
         | 
| 13 | 
            -
                <%= content %>
         | 
| 5 | 
            +
                <% if heroicon? %>
         | 
| 6 | 
            +
                  <%= heroicon %>
         | 
| 7 | 
            +
                <% else %>
         | 
| 8 | 
            +
                  <%= render Ariadne::UI::Heroicon::Component.new(icon: "chevron-down", size: :sm, variant: :solid, html_attrs: { class: "ariadne-transition-transform ariadne-duration-200 ariadne-opacity-50" }) %>
         | 
| 9 | 
            +
                <% end %>
         | 
| 14 10 | 
             
              </div>
         | 
| 11 | 
            +
            </button>
         | 
| 12 | 
            +
            <div class="<%= style(:content) %>" data-<%= Ariadne::UI::Accordion::Component.stimulus_name %>-target="content">
         | 
| 13 | 
            +
              <%= content %>
         | 
| 14 | 
            +
            </div>
         | 
| 15 15 | 
             
            </div>
         | 
| @@ -4,15 +4,24 @@ module Ariadne | |
| 4 4 | 
             
              module UI
         | 
| 5 5 | 
             
                module Accordion
         | 
| 6 6 | 
             
                  module Item
         | 
| 7 | 
            +
                    # The item stored within the accordion.
         | 
| 7 8 | 
             
                    class Component < Ariadne::BaseComponent
         | 
| 9 | 
            +
                      # @param [String] text The of the accordion item.
         | 
| 8 10 | 
             
                      option :text
         | 
| 9 11 |  | 
| 12 | 
            +
                      # Trailing visual at the left of the badge text.
         | 
| 13 | 
            +
                      #
         | 
| 14 | 
            +
                      # @param options [Hash] Same arguments as <%= link_to_component(Ariadne::UI::Heroicon::Component) %>.
         | 
| 10 15 | 
             
                      renders_one :heroicon, Ariadne::UI::Heroicon::Component
         | 
| 11 16 |  | 
| 12 17 | 
             
                      accepts_html_attributes do |html_attrs|
         | 
| 13 | 
            -
                        html_attrs[:class] =  | 
| 14 | 
            -
             | 
| 15 | 
            -
                         | 
| 18 | 
            +
                        html_attrs[:class] = merge_tailwind_classes([style(:trigger), html_attrs[:class]].join(" "))
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                        component_data_attrs = {
         | 
| 21 | 
            +
                          "#{stimulus_name}-state-value": "closed",
         | 
| 22 | 
            +
                          action: "click->#{stimulus_name}#toggle",
         | 
| 23 | 
            +
                        }
         | 
| 24 | 
            +
                        html_attrs[:data] = merge_data_attributes(html_attrs, component_data_attrs)
         | 
| 16 25 | 
             
                      end
         | 
| 17 26 |  | 
| 18 27 | 
             
                      style(:item) do
         | 
| @@ -1,7 +1,9 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
               | 
| 3 | 
            -
             | 
| 4 | 
            -
               | 
| 5 | 
            -
                <%=  | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 1 | 
            +
            <span>
         | 
| 2 | 
            +
              <% if src %>
         | 
| 3 | 
            +
                <%= render Ariadne::UI::Image::Component.new(src:, alt:, size:, html_attrs: ) %>
         | 
| 4 | 
            +
              <% else %>
         | 
| 5 | 
            +
                <span class="<%= html_attrs[:class] %>" <%= html_attributes %>>
         | 
| 6 | 
            +
                  <%= placeholder_text %>
         | 
| 7 | 
            +
                </span>
         | 
| 8 | 
            +
                <% end %>
         | 
| 9 | 
            +
              </span>
         | 
| @@ -4,17 +4,46 @@ | |
| 4 4 | 
             
            module Ariadne
         | 
| 5 5 | 
             
              module UI
         | 
| 6 6 | 
             
                module Avatar
         | 
| 7 | 
            +
                  # A component that can represent a user or entity with an image or initials.
         | 
| 8 | 
            +
                  #
         | 
| 9 | 
            +
                  # @accessibility
         | 
| 10 | 
            +
                  #   Images should have text alternatives that describe the information or function represented.
         | 
| 11 | 
            +
                  #   If the avatar functions as a link, provide alt text that helps convey the function. For instance,
         | 
| 12 | 
            +
                  #   if `Avatar` is a link to a user profile, the alt attribute should be `@kittenuser profile`
         | 
| 13 | 
            +
                  #   rather than `@kittenuser`.
         | 
| 14 | 
            +
                  #   [Learn more about best image practices (WAI Images)](https://www.w3.org/WAI/tutorials/images/)
         | 
| 7 15 | 
             
                  class Component < Ariadne::BaseComponent
         | 
| 8 | 
            -
                     | 
| 16 | 
            +
                    # @param [String] initials The text to show if no `src` is provided.
         | 
| 17 | 
            +
                    option :text, optional: true
         | 
| 18 | 
            +
                    # @param [String] src The avatar's URL.
         | 
| 9 19 | 
             
                    option :src, optional: true
         | 
| 10 | 
            -
                     | 
| 11 | 
            -
                    option : | 
| 20 | 
            +
                    # @param [String] size The avatar's alt text.
         | 
| 21 | 
            +
                    option :alt, optional: true
         | 
| 22 | 
            +
                    # @param [String] size (Ariadne::UI::Badge::DEFAULT_SIZE) The avatar's size. <%= one_of(Ariadne::SizeHelper::VALID_SIZES) %>
         | 
| 23 | 
            +
                    option :size, default: proc { :md }
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    DEFAULT_SHAPE = :circle
         | 
| 26 | 
            +
                    SHAPE_OPTIONS = [DEFAULT_SHAPE, :square].freeze
         | 
| 27 | 
            +
                    # @param [Symbol] shape Shape of the avatar. <%= one_of(Ariadne::UI::Avatar::Component::SHAPE_OPTIONS) %>
         | 
| 28 | 
            +
                    option :shape, default: proc { DEFAULT_SHAPE }
         | 
| 12 29 |  | 
| 13 30 | 
             
                    attr_reader :placeholder_text
         | 
| 14 31 |  | 
| 32 | 
            +
                    accepts_html_attributes do |html_attrs|
         | 
| 33 | 
            +
                      html_attrs[:class] = merge_tailwind_classes([style(size:, shape:, has_src: src.present?), html_attrs[:class]].join(" "))
         | 
| 34 | 
            +
                    end
         | 
| 35 | 
            +
             | 
| 15 36 | 
             
                    style do
         | 
| 16 37 | 
             
                      base do
         | 
| 17 | 
            -
                         | 
| 38 | 
            +
                        [
         | 
| 39 | 
            +
                          "ariadne-select-none",
         | 
| 40 | 
            +
                          "ariadne-object-cover",
         | 
| 41 | 
            +
                          "ariadne-outline",
         | 
| 42 | 
            +
                          "ariadne-outline-1",
         | 
| 43 | 
            +
                          "-ariadne-outline-offset-1",
         | 
| 44 | 
            +
                          "ariadne-outline-black/20",
         | 
| 45 | 
            +
                          "dark:ariadne-outline-white/20",
         | 
| 46 | 
            +
                        ]
         | 
| 18 47 | 
             
                      end
         | 
| 19 48 |  | 
| 20 49 | 
             
                      variants do
         | 
| @@ -25,9 +54,20 @@ module Ariadne | |
| 25 54 | 
             
                          lg { ["ariadne-size-10", "ariadne-text-lg", "ariadne-rounded-lg"] }
         | 
| 26 55 | 
             
                          xl { ["ariadne-size-12", "ariadne-text-xl", "ariadne-rounded-xl"] }
         | 
| 27 56 | 
             
                        end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 57 | 
            +
             | 
| 58 | 
            +
                        shape do
         | 
| 59 | 
            +
                          square do
         | 
| 60 | 
            +
                            []
         | 
| 61 | 
            +
                          end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                          circle do
         | 
| 64 | 
            +
                            [
         | 
| 65 | 
            +
                              "ariadne-rounded-full",
         | 
| 66 | 
            +
                              "*:ariadne-rounded-full",
         | 
| 67 | 
            +
                            ]
         | 
| 68 | 
            +
                          end
         | 
| 30 69 | 
             
                        end
         | 
| 70 | 
            +
             | 
| 31 71 | 
             
                        has_src do
         | 
| 32 72 | 
             
                          no do
         | 
| 33 73 | 
             
                            [
         | 
| @@ -45,8 +85,16 @@ module Ariadne | |
| 45 85 | 
             
                    end
         | 
| 46 86 |  | 
| 47 87 | 
             
                    def before_render
         | 
| 88 | 
            +
                      validate!
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                      # One char long or two
         | 
| 48 91 | 
             
                      len = [:xs, :sm, :md].include?(size) ? 0 : 1
         | 
| 49 | 
            -
                      @placeholder_text = ( | 
| 92 | 
            +
                      @placeholder_text = (text || "").strip.split[0..len].map { |word| word.capitalize[0] }.join
         | 
| 93 | 
            +
                    end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                    private def validate!
         | 
| 96 | 
            +
                      raise ArgumentError, "Must provide either `text` or `src`" if @text.blank? && @src.blank?
         | 
| 97 | 
            +
                      raise ArgumentError, "Must provide only `text` or `src`, not both" if @text.present? && @src.present?
         | 
| 50 98 | 
             
                    end
         | 
| 51 99 | 
             
                  end
         | 
| 52 100 | 
             
                end
         | 
| @@ -4,9 +4,19 @@ | |
| 4 4 | 
             
            module Ariadne
         | 
| 5 5 | 
             
              module UI
         | 
| 6 6 | 
             
                module Badge
         | 
| 7 | 
            +
                  # Use the Badge component to highlight important information.
         | 
| 7 8 | 
             
                  class Component < Ariadne::BaseComponent
         | 
| 9 | 
            +
                    DEFAULT_SIZE = :md
         | 
| 10 | 
            +
                    DEFAULT_COLOR = :none
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                    # @param [String] text The text within the badge.
         | 
| 8 13 | 
             
                    option :text, default: proc { nil }
         | 
| 9 | 
            -
             | 
| 14 | 
            +
             | 
| 15 | 
            +
                    # @param [Symbol] size (Ariadne::UI::Badge::DEFAULT_SIZE) The size of the badge. <%= one_of(Ariadne::SizeHelper::VALID_SIZES) %>
         | 
| 16 | 
            +
                    option :size, default: proc { DEFAULT_SIZE }
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    # @param [Symbol] color (Ariadne::ColorHelper::DEFAULT_COLOR) The color of the badge. <%= one_of(Ariadne::ColorHelper::VALID_COLORS.keys) %>
         | 
| 19 | 
            +
                    option :color, default: proc { DEFAULT_COLOR }
         | 
| 10 20 |  | 
| 11 21 | 
             
                    # Leading visuals appear to the left of the badge text.
         | 
| 12 22 | 
             
                    #
         | 
| @@ -14,23 +24,22 @@ module Ariadne | |
| 14 24 | 
             
                    #
         | 
| 15 25 | 
             
                    # - `leading_visual_heroicon` for a <%= link_to_component(Ariadne::UI::Heroicon::Component) %>.
         | 
| 16 26 | 
             
                    # - `leading_visual_color_dot` for a <%= link_to_component(Ariadne::UI::ColorDot::Component) %>.
         | 
| 27 | 
            +
                    #
         | 
| 28 | 
            +
                    # @param options [Hash] Same arguments as <%= link_to_component(Ariadne::UI::Heroicon::Component) %> and <%= link_to_component(Ariadne::UI::ColorDot::Component) %>.
         | 
| 17 29 | 
             
                    renders_one :leading_visual, types: {
         | 
| 18 | 
            -
                      heroicon:  | 
| 19 | 
            -
             | 
| 20 | 
            -
                        Ariadne::UI::Heroicon::Component.new(**options)
         | 
| 21 | 
            -
                      },
         | 
| 22 | 
            -
                      color_dot: lambda { |**options|
         | 
| 23 | 
            -
                        options[:size] = size # Use the same size as the badge
         | 
| 24 | 
            -
                        Ariadne::UI::ColorDot::Component.new(**options)
         | 
| 25 | 
            -
                      },
         | 
| 30 | 
            +
                      heroicon: Ariadne::UI::Heroicon::Component,
         | 
| 31 | 
            +
                      color_dot: Ariadne::UI::ColorDot::Component,
         | 
| 26 32 | 
             
                    }
         | 
| 27 33 |  | 
| 28 34 | 
             
                    include Ariadne::Behaviors::Tooltipable
         | 
| 29 35 |  | 
| 30 | 
            -
                     | 
| 31 | 
            -
                     | 
| 36 | 
            +
                    accepts_html_attributes do |html_attrs|
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    # must be done here rather than within an `accepts_html_attributes` block
         | 
| 40 | 
            +
                    # because the padding class is dependent on the `with_leading_item` slot's existence, which isn't known until now
         | 
| 32 41 | 
             
                    def before_render
         | 
| 33 | 
            -
                      html_attrs[:class] =  | 
| 42 | 
            +
                      html_attrs[:class] = merge_tailwind_classes([style(size:, color:, with_leading_item: leading_visual ? :yes : :no), html_attrs[:class]].join(" "))
         | 
| 34 43 | 
             
                    end
         | 
| 35 44 |  | 
| 36 45 | 
             
                    style do
         | 
| @@ -38,7 +47,7 @@ module Ariadne | |
| 38 47 | 
             
                        [
         | 
| 39 48 | 
             
                          "ariadne-truncate",
         | 
| 40 49 | 
             
                          "ariadne-max-w-full",
         | 
| 41 | 
            -
                          "ariadne-border | 
| 50 | 
            +
                          "ariadne-border",
         | 
| 42 51 | 
             
                          "ariadne-border-solid",
         | 
| 43 52 | 
             
                          "ariadne-border-black/10",
         | 
| 44 53 | 
             
                          "dark:ariadne-border-white/10",
         | 
| @@ -56,15 +65,25 @@ module Ariadne | |
| 56 65 | 
             
                      end
         | 
| 57 66 |  | 
| 58 67 | 
             
                      variants do
         | 
| 68 | 
            +
                        extend Ariadne::ColorHelper
         | 
| 69 | 
            +
                        include_colors!
         | 
| 70 | 
            +
             | 
| 59 71 | 
             
                        with_leading_item do
         | 
| 60 72 | 
             
                          yes { "ariadne-inline-flex ariadne-items-center" }
         | 
| 61 73 | 
             
                          no { "ariadne-inline-block" }
         | 
| 62 74 | 
             
                        end
         | 
| 63 75 |  | 
| 76 | 
            +
                        theme do
         | 
| 77 | 
            +
                          outline { "ariadne-bg-transparent ariadne-text-blue-400 ariadne-border-blue-400" }
         | 
| 78 | 
            +
                          ghost { "ariadne-bg-blue-400 ariadne-text-white ariadne-border-blue-400" }
         | 
| 79 | 
            +
                        end
         | 
| 80 | 
            +
             | 
| 64 81 | 
             
                        size do
         | 
| 65 | 
            -
                          xs { "ariadne- | 
| 66 | 
            -
                          sm { "ariadne- | 
| 67 | 
            -
                          md { "ariadne- | 
| 82 | 
            +
                          xs { "ariadne-text-xs ariadne-leading-3" }
         | 
| 83 | 
            +
                          sm { "ariadne-text-xs ariadne-leading-4" }
         | 
| 84 | 
            +
                          md { "ariadne-text-base ariadne-leading-5" }
         | 
| 85 | 
            +
                          lg { "ariadne-text-lg ariadne-leading-6" }
         | 
| 86 | 
            +
                          xl { "ariadne-text-xl ariadne-leading-8" }
         | 
| 68 87 | 
             
                        end
         | 
| 69 88 | 
             
                      end
         | 
| 70 89 |  | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            <div class="<%= html_attrs[:class] %>" <%= html_attributes %>>
         | 
| 2 | 
            +
              <section aria-labelledby="<%= @header_id %>" class="ariadne-p-4">
         | 
| 3 | 
            +
                <div class="ariadne-flex ariadne-items-center">
         | 
| 4 | 
            +
                  <div class="ariadne-flex-shrink-0 <%= style(:text, scheme:) %>">
         | 
| 5 | 
            +
                    <%= render heroicon_or_default %>
         | 
| 6 | 
            +
                  </div>
         | 
| 7 | 
            +
                  <div class="ariadne-ml-3 ariadne-w-0 ariadne-flex-1 ariadne-pt-0.5 <%= style(:text, scheme:) %>">
         | 
| 8 | 
            +
                    <p id="<%= @header_id %>" class="ariadne-text-sm ariadne-font-semibold" data-<%= Ariadne::UI::Banner::Component.stimulus_name %>-target="title"><%= title %></p>
         | 
| 9 | 
            +
                    <p class="ariadne-mt-1 ariadne-text-sm" data-<%= Ariadne::UI::Banner::Component.stimulus_name %>-target="message"><%= content %></p>
         | 
| 10 | 
            +
                  </div>
         | 
| 11 | 
            +
                  <% if action %>
         | 
| 12 | 
            +
                    <div class="ariadne-flex">
         | 
| 13 | 
            +
                      <%= action %>
         | 
| 14 | 
            +
                    </div>
         | 
| 15 | 
            +
                  <% end %>
         | 
| 16 | 
            +
                  <div class="ariadne-ml-4 ariadne-flex ariadne-flex-shrink-0 ">
         | 
| 17 | 
            +
                    <% if @dismissible %>
         | 
| 18 | 
            +
                      <%= render Ariadne::UI::Button::Component.new(scheme: :nude, html_attrs: { class: style(:dismissable, scheme:), aria: { label: dismiss_label }, data: { action: "click->#{stimulus_name}#dismiss" } }).as_icon(icon: "x-mark", variant: :outline) %>
         | 
| 19 | 
            +
                    <% end %>
         | 
| 20 | 
            +
                  </div>
         | 
| 21 | 
            +
                </div>
         | 
| 22 | 
            +
              </section>
         | 
| 23 | 
            +
            </div>
         |