ariadne_view_components 0.0.12-x64-mingw-ucrt → 0.0.14-x64-mingw-ucrt
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/app/assets/javascripts/ariadne.d.ts +1 -0
- data/app/assets/javascripts/ariadne_view_components.js +2 -2
- data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
- data/app/assets/javascripts/comment-component.d.ts +1 -2
- data/app/assets/javascripts/tab-container-component.d.ts +1 -0
- data/app/assets/javascripts/tab-nav-component.d.ts +9 -0
- data/app/assets/stylesheets/ariadne_view_components.css +1 -0
- data/app/assets/stylesheets/dropdown.css +46 -0
- data/app/assets/stylesheets/tooltip-component.css +8 -8
- data/app/components/ariadne/ariadne.ts +3 -2
- data/app/components/ariadne/avatar_component.rb +81 -0
- data/app/components/ariadne/avatar_stack_component.html.erb +12 -0
- data/app/components/ariadne/avatar_stack_component.rb +75 -0
- data/app/components/ariadne/base_button.rb +13 -4
- data/app/components/ariadne/blankslate_component.rb +4 -4
- data/app/components/ariadne/body_component.rb +1 -1
- data/app/components/ariadne/button_component.html.erb +1 -1
- data/app/components/ariadne/button_component.rb +11 -5
- data/app/components/ariadne/comment-component.ts +32 -50
- data/app/components/ariadne/comment_component.html.erb +31 -13
- data/app/components/ariadne/comment_component.rb +18 -6
- data/app/components/ariadne/component.rb +3 -5
- data/app/components/ariadne/container_component.rb +1 -1
- data/app/components/ariadne/counter_component.rb +1 -1
- data/app/components/ariadne/details_component.html.erb +4 -0
- data/app/components/ariadne/details_component.rb +80 -0
- data/app/components/ariadne/dropdown/menu_component.html.erb +20 -0
- data/app/components/ariadne/dropdown/menu_component.rb +101 -0
- data/app/components/ariadne/dropdown/menu_component.ts +1 -0
- data/app/components/ariadne/dropdown_component.html.erb +8 -0
- data/app/components/ariadne/dropdown_component.rb +172 -0
- data/app/components/ariadne/flash_component.rb +1 -1
- data/app/components/ariadne/flex_component.rb +2 -2
- data/app/components/ariadne/footer_component.html.erb +1 -1
- data/app/components/ariadne/footer_component.rb +1 -1
- data/app/components/ariadne/grid_component.html.erb +2 -2
- data/app/components/ariadne/grid_component.rb +10 -8
- data/app/components/ariadne/header_component.rb +3 -3
- data/app/components/ariadne/heroicon_component.html.erb +1 -1
- data/app/components/ariadne/heroicon_component.rb +7 -6
- data/app/components/ariadne/inline_flex_component.html.erb +1 -0
- data/app/components/ariadne/inline_flex_component.rb +8 -1
- data/app/components/ariadne/link_component.rb +2 -2
- data/app/components/ariadne/list_component.html.erb +2 -11
- data/app/components/ariadne/list_component.rb +11 -15
- data/app/components/ariadne/main_component.rb +2 -2
- data/app/components/ariadne/narrow_container_component.rb +1 -1
- data/app/components/ariadne/panel_bar_component.rb +2 -2
- data/app/components/ariadne/pill_component.rb +20 -6
- data/app/components/ariadne/rich-text-area-component.ts +4 -4
- data/app/components/ariadne/rich_text_area_component.html.erb +2 -2
- data/app/components/ariadne/rich_text_area_component.rb +2 -2
- data/app/components/ariadne/slideover_component.html.erb +1 -1
- data/app/components/ariadne/slideover_component.rb +2 -2
- data/app/components/ariadne/tab-container-component.ts +24 -0
- data/app/components/ariadne/tab-nav-component.ts +34 -0
- data/app/components/ariadne/tab_component.html.erb +2 -6
- data/app/components/ariadne/tab_component.rb +75 -19
- data/app/components/ariadne/tab_container_component.erb +12 -0
- data/app/components/ariadne/tab_container_component.rb +67 -0
- data/app/components/ariadne/tab_nav_component.html.erb +7 -0
- data/app/components/ariadne/tab_nav_component.rb +72 -0
- data/app/components/ariadne/table_nav_component.html.erb +52 -0
- data/app/components/ariadne/table_nav_component.rb +338 -0
- data/app/components/ariadne/time_ago_component.rb +1 -1
- data/app/components/ariadne/timeline_component.rb +1 -1
- data/app/components/ariadne/tooltip_component.html.erb +1 -1
- data/app/components/ariadne/tooltip_component.rb +4 -4
- data/app/lib/ariadne/action_view_extensions/form_helper.rb +21 -7
- data/app/lib/ariadne/fetch_or_fallback_helper.rb +11 -3
- data/app/lib/ariadne/form_builder.rb +2 -2
- data/app/lib/ariadne/icon_helper.rb +17 -13
- data/lib/ariadne/view_components/constants.rb +2 -2
- data/lib/ariadne/view_components/statuses.rb +2 -2
- data/lib/ariadne/view_components/version.rb +1 -1
- data/lib/rubocop/config/default.yml +1 -1
- data/lib/tasks/docs.rake +22 -97
- data/static/arguments.yml +151 -23
- data/static/audited_at.json +17 -1
- data/static/classes.yml +160 -268
- data/static/constants.json +208 -40
- data/static/statuses.json +17 -1
- data/tailwind.config.js +28 -19
- metadata +24 -10
- data/app/components/ariadne/tab_bar_component.html.erb +0 -3
- data/app/components/ariadne/tab_bar_component.rb +0 -45
- data/app/lib/ariadne/join_style_arguments_helper.rb +0 -14
- data/app/lib/ariadne/tab_nav_helper.rb +0 -35
- data/app/lib/ariadne/tabbed_component_helper.rb +0 -39
- data/app/lib/ariadne/test_selector_helper.rb +0 -20
- data/app/lib/ariadne/underline_nav_helper.rb +0 -44
@@ -7,7 +7,6 @@ export default class CommentComponent extends Controller {
|
|
7
7
|
SELECTED_TAB_CLASSES: string[];
|
8
8
|
PUBLIC_BACKGROUND_COLOR: string;
|
9
9
|
INTERNAL_BACKGROUND_COLOR: string;
|
10
|
-
connect(): void;
|
11
10
|
toggleTab(): void;
|
12
|
-
toggleBackgrounds(tab: HTMLButtonElement): void;
|
11
|
+
toggleBackgrounds(tab: HTMLButtonElement, publicComment: boolean): void;
|
13
12
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@github/tab-container-element';
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus';
|
2
|
+
export default class TabNavComponent extends Controller {
|
3
|
+
static targets: string[];
|
4
|
+
readonly tabTargets: [HTMLAnchorElement];
|
5
|
+
SELECTED_CLASSES: string[];
|
6
|
+
UNSELECTED_CLASSES: string[];
|
7
|
+
connect(): void;
|
8
|
+
toggle(event: Event): void;
|
9
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
.ariadne__details-reset > summary {
|
2
|
+
list-style: none;
|
3
|
+
transition: 80ms cubic-bezier(0.33, 1, 0.68, 1);
|
4
|
+
transition-property: color, background-color, box-shadow, border-color;
|
5
|
+
}
|
6
|
+
|
7
|
+
.ariadne__details-reset > summary:focus {
|
8
|
+
outline: 2px solid var(--color-accent-fg);
|
9
|
+
outline-offset: -2px;
|
10
|
+
box-shadow: none;
|
11
|
+
}
|
12
|
+
|
13
|
+
.ariadne__details-reset > summary:focus:not(:focus-visible) {
|
14
|
+
outline: solid 1px transparent;
|
15
|
+
}
|
16
|
+
|
17
|
+
.ariadne__details-reset > summary:focus-visible {
|
18
|
+
outline: 2px solid var(--color-accent-fg);
|
19
|
+
outline-offset: -2px;
|
20
|
+
box-shadow: none;
|
21
|
+
}
|
22
|
+
|
23
|
+
.ariadne__details-reset > summary.btn-primary:focus {
|
24
|
+
outline: 2px solid var(--color-accent-fg);
|
25
|
+
outline-offset: -2px;
|
26
|
+
box-shadow: inset 0 0 0 3px var(--color-fg-on-emphasis);
|
27
|
+
}
|
28
|
+
|
29
|
+
.ariadne__details-reset > summary.btn-primary:focus:not(:focus-visible) {
|
30
|
+
outline: solid 1px transparent;
|
31
|
+
box-shadow: none;
|
32
|
+
}
|
33
|
+
|
34
|
+
.ariadne__details-reset > summary.btn-primary:focus-visible {
|
35
|
+
outline: 2px solid var(--color-accent-fg);
|
36
|
+
outline-offset: -2px;
|
37
|
+
box-shadow: inset 0 0 0 3px var(--color-fg-on-emphasis);
|
38
|
+
}
|
39
|
+
|
40
|
+
.ariadne__details-reset > summary::before {
|
41
|
+
display: none;
|
42
|
+
}
|
43
|
+
|
44
|
+
.ariadne__details-reset > summary::-webkit-details-marker {
|
45
|
+
display: none;
|
46
|
+
}
|
@@ -1,34 +1,34 @@
|
|
1
|
-
.tooltip-arrow,
|
2
|
-
.tooltip-arrow::before {
|
1
|
+
.ariadne-tooltip-arrow,
|
2
|
+
.ariadne-tooltip-arrow::before {
|
3
3
|
position: absolute;
|
4
4
|
width: 8px;
|
5
5
|
height: 8px;
|
6
6
|
background: inherit;
|
7
7
|
}
|
8
8
|
|
9
|
-
.tooltip-arrow {
|
9
|
+
.ariadne-tooltip-arrow {
|
10
10
|
visibility: hidden;
|
11
11
|
}
|
12
12
|
|
13
|
-
tooltip[data-tooltip-show] .tooltip-arrow::before {
|
13
|
+
tooltip[data-tooltip-show] .ariadne-tooltip-arrow::before {
|
14
14
|
visibility: visible;
|
15
15
|
content: '';
|
16
16
|
transform: rotate(45deg);
|
17
17
|
}
|
18
18
|
|
19
|
-
tooltip[data-popper-placement^='top'][data-tooltip-show] > .tooltip-arrow {
|
19
|
+
tooltip[data-popper-placement^='top'][data-tooltip-show] > .ariadne-tooltip-arrow {
|
20
20
|
bottom: -4px;
|
21
21
|
}
|
22
22
|
|
23
|
-
tooltip[data-popper-placement^='bottom'] > .tooltip-arrow {
|
23
|
+
tooltip[data-popper-placement^='bottom'] > .ariadne-tooltip-arrow {
|
24
24
|
top: -4px;
|
25
25
|
}
|
26
26
|
|
27
|
-
tooltip[data-popper-placement^='left'] > .tooltip-arrow {
|
27
|
+
tooltip[data-popper-placement^='left'] > .ariadne-tooltip-arrow {
|
28
28
|
right: -4px;
|
29
29
|
}
|
30
30
|
|
31
|
-
tooltip[data-popper-placement^='right'] > .tooltip-arrow {
|
31
|
+
tooltip[data-popper-placement^='right'] > .ariadne-tooltip-arrow {
|
32
32
|
left: -4px;
|
33
33
|
}
|
34
34
|
|
@@ -3,18 +3,19 @@ import {Application} from '@hotwired/stimulus'
|
|
3
3
|
import AriadneForm from './ariadne-form'
|
4
4
|
|
5
5
|
import ClipboardCopyComponent from './clipboard-copy-component'
|
6
|
-
import CommentComponent from './comment-component'
|
7
6
|
import RichTextAreaComponent from './rich-text-area-component'
|
8
7
|
import SlideoverComponent from './slideover-component'
|
8
|
+
import TabNavComponent from './tab-nav-component'
|
9
9
|
import TooltipComponent from './tooltip-component'
|
10
10
|
|
11
|
+
import './tab-container-component'
|
11
12
|
import './time-ago-component'
|
12
13
|
|
13
14
|
const application = Application.start()
|
14
15
|
|
15
16
|
application.register('clipboard-copy-component', ClipboardCopyComponent)
|
16
17
|
application.register('ariadne-form', AriadneForm)
|
17
|
-
application.register('comment-component', CommentComponent)
|
18
18
|
application.register('rich-text-area-component', RichTextAreaComponent)
|
19
19
|
application.register('slideover-component', SlideoverComponent)
|
20
|
+
application.register('tab-nav-component', TabNavComponent)
|
20
21
|
application.register('tooltip-component', TooltipComponent)
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ariadne
|
4
|
+
# `Avatar` can be used to represent users.
|
5
|
+
#
|
6
|
+
# - Use the default circle avatar for users, and the square shape
|
7
|
+
# for or any other non-human avatars.
|
8
|
+
# - By default, `Avatar` will render a static `<img>`. To have `Avatar` function as a link, set the `href` which will wrap the `<img>` in a `<a>`.
|
9
|
+
# - Set `size` to update the height and width of the `Avatar` in pixels.
|
10
|
+
# - To stack multiple avatars together, use <%= link_to_component(Ariadne::AvatarStackComponent) %>.
|
11
|
+
#
|
12
|
+
# @accessibility
|
13
|
+
# Images should have text alternatives that describe the information or function represented.
|
14
|
+
# If the avatar functions as a link, provide alt text that helps convey the function. For instance,
|
15
|
+
# if `Avatar` is a link to a user profile, the alt attribute should be `@kittenuser profile`
|
16
|
+
# rather than `@kittenuser`.
|
17
|
+
# [Learn more about best image practices (WAI Images)](https://www.w3.org/WAI/tutorials/images/)
|
18
|
+
class AvatarComponent < Ariadne::Component
|
19
|
+
DEFAULT_SIZE = 20
|
20
|
+
SMALL_THRESHOLD = 24
|
21
|
+
|
22
|
+
DEFAULT_SHAPE = :circle
|
23
|
+
SHAPE_OPTIONS = [DEFAULT_SHAPE, :square].freeze
|
24
|
+
|
25
|
+
SIZE_OPTIONS = [16, DEFAULT_SIZE, SMALL_THRESHOLD, 32, 40, 48, 80].freeze
|
26
|
+
|
27
|
+
DEFAULT_CLASSES = "ariadne-inline-block ariadne-rounded-full ariadne-ring-2 ariadne-ring-white"
|
28
|
+
|
29
|
+
# @example Default
|
30
|
+
# <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser")) %>
|
31
|
+
#
|
32
|
+
# @example Square
|
33
|
+
# <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", shape: :square)) %>
|
34
|
+
#
|
35
|
+
# @example Link
|
36
|
+
# <%= render(Ariadne::AvatarComponent.new(href: "#", src: "http://placekitten.com/200/200", alt: "@kittenuser profile")) %>
|
37
|
+
#
|
38
|
+
# @example With size
|
39
|
+
# <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 16)) %>
|
40
|
+
# <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 20)) %>
|
41
|
+
# <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 24)) %>
|
42
|
+
# <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 32)) %>
|
43
|
+
# <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 40)) %>
|
44
|
+
# <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 48)) %>
|
45
|
+
# <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 80)) %>
|
46
|
+
#
|
47
|
+
# @param src [String] The source url of the avatar image.
|
48
|
+
# @param alt [String] Passed through to alt on img tag.
|
49
|
+
# @param size [Integer] <%= one_of(Ariadne::AvatarComponent::SIZE_OPTIONS) %>
|
50
|
+
# @param shape [Symbol] Shape of the avatar. <%= one_of(Ariadne::AvatarComponent::SHAPE_OPTIONS) %>
|
51
|
+
# @param href [String] The URL to link to. If used, component will be wrapped by an `<a>` tag.
|
52
|
+
# @param classes [String] <%= link_to_classes_docs %>
|
53
|
+
# @param attributes [Hash] <%= link_to_attributes_docs %>
|
54
|
+
def initialize(src:, alt:, size: DEFAULT_SIZE, shape: DEFAULT_SHAPE, href: nil, classes: "", attributes: {})
|
55
|
+
@tag = :img
|
56
|
+
@href = href
|
57
|
+
|
58
|
+
@classes = class_names(
|
59
|
+
DEFAULT_CLASSES,
|
60
|
+
classes,
|
61
|
+
)
|
62
|
+
|
63
|
+
@attributes = attributes
|
64
|
+
@attributes[:src] = src
|
65
|
+
@attributes[:alt] = alt
|
66
|
+
@attributes[:size] = fetch_or_raise(SIZE_OPTIONS, size)
|
67
|
+
@attributes[:height] = @attributes[:size]
|
68
|
+
@attributes[:width] = @attributes[:size]
|
69
|
+
end
|
70
|
+
|
71
|
+
def call
|
72
|
+
if @href
|
73
|
+
render(Ariadne::LinkComponent.new(href: @href, classes: @classes, attributes: @attributes)) do
|
74
|
+
render(Ariadne::BaseComponent.new(tag: @tag)) { content }
|
75
|
+
end
|
76
|
+
else
|
77
|
+
render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) { content }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do %>
|
2
|
+
<%if tooltipped? %>
|
3
|
+
<%= tooltip.to_s %>
|
4
|
+
<% avatars.each_with_index do |avatar, i| %>
|
5
|
+
<%= avatar %>
|
6
|
+
<% end %>
|
7
|
+
<% else %>
|
8
|
+
<% avatars.each_with_index do |avatar, i| %>
|
9
|
+
<%= avatar %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ariadne
|
4
|
+
# Use `AvatarStack` to stack multiple avatars together.
|
5
|
+
class AvatarStackComponent < Ariadne::Component
|
6
|
+
ALIGN_DEFAULT = :left
|
7
|
+
ALIGN_OPTIONS = [ALIGN_DEFAULT, :right].freeze
|
8
|
+
|
9
|
+
DEFAULT_TAG = :div
|
10
|
+
TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
|
11
|
+
|
12
|
+
DEFAULT_BODY_TAG = :div
|
13
|
+
BODY_TAG_OPTIONS = [DEFAULT_BODY_TAG, :span].freeze
|
14
|
+
|
15
|
+
# `Tooltip` that appears on mouse hover or keyboard focus over the stack.
|
16
|
+
#
|
17
|
+
# @param tag [Symbol, String] The rendered tag name
|
18
|
+
# @param text [String] The text content of the tooltip. This should be brief and no longer than a sentence.
|
19
|
+
# @param direction [Symbol] <%= one_of(Ariadne::TooltipComponent::VALID_PLACEMENTS) %>
|
20
|
+
# @param classes [String] <%= link_to_classes_docs %>
|
21
|
+
# @param attributes [Hash] Same arguments as <%= link_to_component(Ariadne::TooltipComponent) %>.
|
22
|
+
renders_one :tooltip, lambda { |tag: Ariadne::TooltipComponent::DEFAULT_TAG, text:, direction: Ariadne::TooltipComponent::DEFAULT_PLACEMENT, classes: "", attributes: {}|
|
23
|
+
raise ArgumentError, "Avatar stacks with a tooltip must have a unique `id` set." if @id.blank?
|
24
|
+
|
25
|
+
Ariadne::TooltipComponent.new(for_id: @id, tag: tag, text: text, direction: direction, type: :label, classes: classes, attributes: attributes)
|
26
|
+
}
|
27
|
+
|
28
|
+
# Required list of stacked avatars.
|
29
|
+
#
|
30
|
+
# @param classes [String] <%= link_to_classes_docs %>
|
31
|
+
# @param attributes [Hash] <%= link_to_attributes_docs %>
|
32
|
+
renders_many :avatars, "Ariadne::AvatarComponent"
|
33
|
+
|
34
|
+
DEFAULT_CLASSES = "ariadne-flex ariadne--space-x-2 ariadne-overflow-hidden"
|
35
|
+
|
36
|
+
# @example Default
|
37
|
+
# <%= render(Ariadne::AvatarStackComponent.new) do |c| %>
|
38
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
39
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
40
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
41
|
+
# <% end %>
|
42
|
+
#
|
43
|
+
# @example Align right
|
44
|
+
# <%= render(Ariadne::AvatarStackComponent.new(align: :right)) do |c| %>
|
45
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
46
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
47
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
48
|
+
# <% end %>
|
49
|
+
#
|
50
|
+
# @param tag [Symbol] <%= one_of(Ariadne::AvatarStackComponent::TAG_OPTIONS) %>
|
51
|
+
# @param align [Symbol] <%= one_of(Ariadne::AvatarStackComponent::ALIGN_OPTIONS) %>
|
52
|
+
# @param classes [String] <%= link_to_classes_docs %>
|
53
|
+
# @param attributes [Hash] <%= link_to_attributes_docs %>
|
54
|
+
def initialize(tag: DEFAULT_TAG, align: ALIGN_DEFAULT, classes: "", attributes: {})
|
55
|
+
@tag = check_incoming_tag(DEFAULT_TAG, tag)
|
56
|
+
@align = fetch_or_raise(ALIGN_OPTIONS, align)
|
57
|
+
@classes = class_names(
|
58
|
+
DEFAULT_CLASSES,
|
59
|
+
classes,
|
60
|
+
)
|
61
|
+
|
62
|
+
@attributes = attributes
|
63
|
+
@attributes[:id] ||= "avatar-stack-#{SecureRandom.hex(4)}"
|
64
|
+
@id = @attributes[:id]
|
65
|
+
end
|
66
|
+
|
67
|
+
def render?
|
68
|
+
avatars.any?
|
69
|
+
end
|
70
|
+
|
71
|
+
def tooltipped?
|
72
|
+
tooltip.present?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -8,7 +8,7 @@ module Ariadne
|
|
8
8
|
|
9
9
|
DEFAULT_TYPE = :button
|
10
10
|
TYPE_SUBMIT = :submit
|
11
|
-
|
11
|
+
VALID_TYPES = [DEFAULT_TYPE, :reset, TYPE_SUBMIT].freeze
|
12
12
|
|
13
13
|
SIZE_CLASS_MAPPINGS = {
|
14
14
|
xs: "ariadne-px-2.5 ariadne-py-1.5 ariadne-text-xs ariadne-font-medium ariadne-rounded",
|
@@ -20,6 +20,7 @@ module Ariadne
|
|
20
20
|
VALID_SIZES = SIZE_CLASS_MAPPINGS.keys.freeze
|
21
21
|
|
22
22
|
DEFAULT_CLASSES = "ariadne-inline-flex ariadne-items-center ariadne-border ariadne-shadow-sm focus:ariadne-outline-none focus:ariadne-ring-2 focus:ariadne-ring-offset-2"
|
23
|
+
DEFAULT_NUDE_CLASSES = "ariadne-inline-flex focus:ariadne-outline-none focus:ariadne-ring-2 focus:ariadne-ring-offset-2"
|
23
24
|
|
24
25
|
DEFAULT_SIZE = :md
|
25
26
|
|
@@ -31,7 +32,7 @@ module Ariadne
|
|
31
32
|
# <%= render(Ariadne::BaseButton.new(size: :xl)) { "I am an extra large button!" } %>
|
32
33
|
#
|
33
34
|
# @param tag [Symbol] <%= one_of(Ariadne::BaseButton::TAG_OPTIONS) %>
|
34
|
-
# @param type [Symbol] <%= one_of(Ariadne::BaseButton::
|
35
|
+
# @param type [Symbol] <%= one_of(Ariadne::BaseButton::VALID_TYPES) %>
|
35
36
|
# @param size [Symbol] <%= one_of(Ariadne::BaseButton::VALID_SIZES) %>
|
36
37
|
# @param classes [String] <%= link_to_classes_docs %>
|
37
38
|
# @param attributes [Hash] <%= link_to_attributes_docs %>
|
@@ -46,14 +47,22 @@ module Ariadne
|
|
46
47
|
@tag = fetch_or_raise(TAG_OPTIONS, tag)
|
47
48
|
@size = fetch_or_raise(VALID_SIZES, size)
|
48
49
|
|
49
|
-
|
50
|
-
|
50
|
+
if button?
|
51
|
+
@attributes[:type] = fetch_or_raise(VALID_TYPES, type)
|
52
|
+
@classes = class_names(DEFAULT_CLASSES, SIZE_CLASS_MAPPINGS[@size], classes)
|
53
|
+
else
|
54
|
+
@classes = class_names(DEFAULT_NUDE_CLASSES, SIZE_CLASS_MAPPINGS[@size], classes)
|
55
|
+
end
|
51
56
|
end
|
52
57
|
|
53
58
|
def call
|
54
59
|
render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) { content }
|
55
60
|
end
|
56
61
|
|
62
|
+
private def link?(type)
|
63
|
+
type == :link
|
64
|
+
end
|
65
|
+
|
57
66
|
private def button?
|
58
67
|
@tag == :button
|
59
68
|
end
|
@@ -50,7 +50,7 @@ module Ariadne
|
|
50
50
|
# @param tag [Symbol, String] <%= one_of(Ariadne::HeadingComponent::TAG_OPTIONS) %>
|
51
51
|
# @param classes [String] <%= link_to_classes_docs %>
|
52
52
|
# @param attributes [Hash] Same arguments as <%= link_to_component(Ariadne::HeroiconComponent) %>.
|
53
|
-
DEFAULT_HEADING_CLASSES = "text-3xl font-extrabold tracking-tight text-gray-900 sm:text-4xl"
|
53
|
+
DEFAULT_HEADING_CLASSES = "ariadne-text-3xl ariadne-font-extrabold ariadne-tracking-tight ariadne-text-gray-900 sm:ariadne-text-4xl"
|
54
54
|
renders_one :heading, lambda { |tag: :h1, classes: "", attributes: {}|
|
55
55
|
actual_classes = class_names(DEFAULT_HEADING_CLASSES, classes)
|
56
56
|
|
@@ -107,7 +107,7 @@ module Ariadne
|
|
107
107
|
|
108
108
|
# @example Basic
|
109
109
|
# <%= render Ariadne::BlankslateComponent.new do |c| %>
|
110
|
-
# <% c.heading(tag: :h2)
|
110
|
+
# <% c.heading(tag: :h2) { "heading" } %>
|
111
111
|
# <% c.description { "Description"} %>
|
112
112
|
# <% end %>
|
113
113
|
#
|
@@ -117,7 +117,7 @@ module Ariadne
|
|
117
117
|
# @code
|
118
118
|
# <%= render Ariadne::BlankslateComponent.new do |c| %>
|
119
119
|
# <% c.icon(icon: :"globe-europe-africa") %>
|
120
|
-
# <% c.heading(tag: :h2)
|
120
|
+
# <% c.heading(tag: :h2) { "heading" } %>
|
121
121
|
# <% c.description { "Description"} %>
|
122
122
|
# <% end %>
|
123
123
|
#
|
@@ -127,7 +127,7 @@ module Ariadne
|
|
127
127
|
# @code
|
128
128
|
# <%= render Ariadne::BlankslateComponent.new do |c| %>
|
129
129
|
# <% c.image(src: "https://github.githubassets.com/images/modules/site/features/security-icon.svg", alt: "Security - secure vault") %>
|
130
|
-
# <% c.heading(tag: :h2)
|
130
|
+
# <% c.heading(tag: :h2){ "heading" } %>
|
131
131
|
# <% end %>
|
132
132
|
#
|
133
133
|
# @param tag [Symbol, String] The rendered tag name
|
@@ -1,4 +1,4 @@
|
|
1
1
|
<%= render Ariadne::BaseButton.new(tag: @tag, type: @type, classes: @classes, attributes: @attributes) do -%>
|
2
|
-
<%= icon %><%= trimmed_content %><%= counter %>
|
2
|
+
<%= icon %><%= trimmed_content %><%= counter %><%= ariadne_heroicon(icon: :"chevron-down", variant: HeroiconsHelper::Icon::VARIANT_MINI, classes: "ariadne-ml-2 ariadne--mr-1") if dropdown? %>
|
3
3
|
<%= tooltip %>
|
4
4
|
<% end -%>
|
@@ -9,6 +9,7 @@ module Ariadne
|
|
9
9
|
LINK_SCHEME = :link
|
10
10
|
|
11
11
|
SCHEME_CLASS_MAPPINGS = {
|
12
|
+
link: Ariadne::LinkComponent::DEFAULT_ACTIONABLE_CLASSES,
|
12
13
|
none: "",
|
13
14
|
default: "ariadne-text-purple-800 ariadne-bg-purple-50 hover:ariadne-bg-purple-100 ariadne-border-purple-300 focus:ariadne-ring-offset-purple-50 focus:ariadne-ring-purple-600",
|
14
15
|
info: "ariadne-text-blue-800 ariadne-bg-blue-50 hover:ariadne-bg-blue-100 ariadne-border-blue-300 focus:ariadne-ring-offset-blue-50 focus:ariadne-ring-blue-600",
|
@@ -82,7 +83,7 @@ module Ariadne
|
|
82
83
|
#
|
83
84
|
# @example With leading visual
|
84
85
|
# <%= render(Ariadne::ButtonComponent.new) do |c| %>
|
85
|
-
# <% c.icon(icon: :star, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, classes: "text-yellow-600") %>
|
86
|
+
# <% c.icon(icon: :star, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, classes: "ariadne-text-yellow-600") %>
|
86
87
|
# Button
|
87
88
|
# <% end %>
|
88
89
|
#
|
@@ -109,10 +110,10 @@ module Ariadne
|
|
109
110
|
# <% end %>
|
110
111
|
#
|
111
112
|
# @param tag [Symbol] <%= one_of(Ariadne::BaseButton::TAG_OPTIONS) %>
|
112
|
-
# @param type [Symbol] <%= one_of(Ariadne::BaseButton::
|
113
|
+
# @param type [Symbol] <%= one_of(Ariadne::BaseButton::VALID_TYPES) %>
|
113
114
|
# @param scheme [Symbol] <%= one_of(Ariadne::ButtonComponent::VALID_SCHEMES) %>
|
114
115
|
# @param size [Symbol] <%= one_of(Ariadne::BaseButton::VALID_SIZES) %>
|
115
|
-
# @param
|
116
|
+
# @param dropdown [Boolean] Whether or not to render a dropdown caret.
|
116
117
|
# @param classes [String] <%= link_to_classes_docs %>
|
117
118
|
# @param attributes [Hash] <%= link_to_attributes_docs %>
|
118
119
|
def initialize(
|
@@ -120,25 +121,30 @@ module Ariadne
|
|
120
121
|
type: Ariadne::BaseButton::DEFAULT_TYPE,
|
121
122
|
scheme: DEFAULT_SCHEME,
|
122
123
|
size: BaseButton::DEFAULT_SIZE,
|
124
|
+
dropdown: false,
|
123
125
|
classes: "",
|
124
126
|
attributes: {}
|
125
127
|
)
|
126
128
|
@tag = tag
|
127
129
|
@type = type
|
128
|
-
@scheme = scheme
|
129
130
|
|
130
131
|
@attributes = attributes
|
131
132
|
@id = @attributes[:id]
|
132
133
|
|
133
134
|
@size = fetch_or_raise(Ariadne::BaseButton::VALID_SIZES, size)
|
134
135
|
@scheme = fetch_or_raise(VALID_SCHEMES, scheme)
|
136
|
+
@scheme = LINK_SCHEME if @tag == :a
|
135
137
|
|
136
138
|
@classes = class_names(
|
137
139
|
SCHEME_CLASS_MAPPINGS[@scheme],
|
138
|
-
classes
|
140
|
+
classes,
|
139
141
|
)
|
140
142
|
end
|
141
143
|
|
144
|
+
private def dropdown?
|
145
|
+
@dropdown
|
146
|
+
end
|
147
|
+
|
142
148
|
private def trimmed_content
|
143
149
|
return if content.blank?
|
144
150
|
|
@@ -1,55 +1,37 @@
|
|
1
|
-
import {Controller} from '@hotwired/stimulus'
|
1
|
+
// import {Controller} from '@hotwired/stimulus'
|
2
2
|
|
3
|
-
export default class CommentComponent extends Controller {
|
4
|
-
|
3
|
+
// export default class CommentComponent extends Controller {
|
4
|
+
// static targets = ['tab', 'tabBarComponent']
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
// declare readonly commentComponentTarget: HTMLDivElement
|
7
|
+
// declare readonly tabBarComponentTarget: HTMLElement // technically a `nav but typescript can't find it?
|
8
|
+
// declare readonly tabTargets: [HTMLButtonElement]
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
// // keep in sync with comment_component.rb
|
11
|
+
// SELECTED_TAB_CLASSES = ['ariadne-border-indigo-500', 'ariadne-text-indigo-600']
|
12
|
+
// PUBLIC_BACKGROUND_COLOR = 'ariadne-bg-white'
|
13
|
+
// INTERNAL_BACKGROUND_COLOR = 'ariadne-bg-internal-message'
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
// toggleTab() {
|
16
|
+
// for (const tab of this.tabTargets) {
|
17
|
+
// if (tab.hasAttribute('aria-selected')) {
|
18
|
+
// tab.classList.remove(...this.SELECTED_TAB_CLASSES)
|
19
|
+
// this.toggleBackgrounds(tab, false)
|
20
|
+
// tab.removeAttribute('aria-selected')
|
21
|
+
// } else {
|
22
|
+
// tab.setAttribute('aria-selected', 'true')
|
23
|
+
// tab.classList.add(...this.SELECTED_TAB_CLASSES)
|
24
|
+
// this.toggleBackgrounds(tab, true)
|
25
|
+
// }
|
26
|
+
// }
|
27
|
+
// }
|
28
|
+
// toggleBackgrounds(tab: HTMLButtonElement, publicComment: boolean) {
|
29
|
+
// if (publicComment) {
|
30
|
+
// this.tabBarComponentTarget.classList.add(this.PUBLIC_BACKGROUND_COLOR)
|
31
|
+
// this.tabBarComponentTarget.classList.remove(this.INTERNAL_BACKGROUND_COLOR)
|
21
32
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
this.toggleBackgrounds(tab)
|
28
|
-
} else {
|
29
|
-
tab.setAttribute('selected', 'true')
|
30
|
-
tab.classList.add(...this.SELECTED_TAB_CLASSES)
|
31
|
-
this.toggleBackgrounds(tab)
|
32
|
-
if (tab.hasAttribute('data-public')) {
|
33
|
-
document.getElementById('message_public')?.setAttribute('value', 'true')
|
34
|
-
} else {
|
35
|
-
document.getElementById('message_public')?.setAttribute('value', 'false')
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
}
|
40
|
-
toggleBackgrounds(tab: HTMLButtonElement) {
|
41
|
-
if (tab.hasAttribute('selected')) {
|
42
|
-
if (tab.hasAttribute('data-public')) {
|
43
|
-
// this.commentComponentTarget.classList.add(this.PUBLIC_BACKGROUND_COLOR)
|
44
|
-
// this.commentComponentTarget.classList.remove(this.INTERNAL_BACKGROUND_COLOR)
|
45
|
-
this.tabBarComponentTarget.classList.add(this.PUBLIC_BACKGROUND_COLOR)
|
46
|
-
this.tabBarComponentTarget.classList.remove(this.INTERNAL_BACKGROUND_COLOR)
|
47
|
-
} else {
|
48
|
-
// this.commentComponentTarget.classList.remove(this.PUBLIC_BACKGROUND_COLOR)
|
49
|
-
// this.commentComponentTarget.classList.add(this.INTERNAL_BACKGROUND_COLOR)
|
50
|
-
this.tabBarComponentTarget.classList.remove(this.PUBLIC_BACKGROUND_COLOR)
|
51
|
-
this.tabBarComponentTarget.classList.add(this.INTERNAL_BACKGROUND_COLOR)
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}
|
55
|
-
}
|
33
|
+
// this.tabBarComponentTarget.classList.remove(this.PUBLIC_BACKGROUND_COLOR)
|
34
|
+
// this.tabBarComponentTarget.classList.add(this.INTERNAL_BACKGROUND_COLOR)
|
35
|
+
// }
|
36
|
+
// }
|
37
|
+
// }
|
@@ -2,21 +2,39 @@
|
|
2
2
|
<div class="ariadne-bg-white" data-comment-component-target="commentComponent">
|
3
3
|
<div class="ariadne-hidden sm:ariadne-block">
|
4
4
|
<div class="ariadne-border-b ariadne-border-gray-200">
|
5
|
-
<%= render(Ariadne::
|
6
|
-
<%= public_tab %>
|
7
|
-
|
5
|
+
<%= render(Ariadne::TabContainerComponent.new(sr_label: @sr_label)) do |tab_container| %>
|
6
|
+
<%= tab_container.tab(id: public_tab.id, selected: public_tab.selected, classes: public_tab.classes, attributes: public_tab.attributes) do |tab| %>
|
7
|
+
<% tab.text { @public_tab_text } %>
|
8
|
+
<% tab.panel do %>
|
9
|
+
<%= ariadne_form_with(url: @url, method: @method, classes: @classes, attributes: @attributes) do |comment_box| %>
|
10
|
+
<div class="ariadne-overflow-hidden ariadne-border-x ariadne-border-b ariadne-border-gray-300 ariadne-shadow-sm focus-within:ariadne-border-indigo-500 focus-within:ariadne-ring-1 focus-within:ariadne-ring-indigo-500">
|
11
|
+
<%= hidden_field_tag 'message_public', true %>
|
12
|
+
<%= render(Ariadne::RichTextAreaComponent.new(name: :bodytext, sr_label: "Select reply type", attributes: { required: true})) %>
|
13
|
+
<% comment_box.submit { @submit } %>
|
14
|
+
</div>
|
15
|
+
<div class="ariadne-mt-2 ariadne-flex ariadne-justify-end">
|
16
|
+
<%= submit %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
<%= tab_container.tab(id: internal_tab.id, selected: internal_tab.selected, classes: internal_tab.classes, attributes: internal_tab.attributes) do |tab| %>
|
22
|
+
<% tab.text { @internal_tab_text } %>
|
23
|
+
<% tab.panel do %>
|
24
|
+
<%= ariadne_form_with(url: @url, method: @method, classes: @classes, attributes: @attributes) do |comment_box| %>
|
25
|
+
<div class="ariadne-overflow-hidden ariadne-border-x ariadne-border-b ariadne-border-gray-300 ariadne-shadow-sm focus-within:ariadne-border-indigo-500 focus-within:ariadne-ring-1 focus-within:ariadne-ring-indigo-500">
|
26
|
+
<%= hidden_field_tag 'message_public', false %>
|
27
|
+
<%= render(Ariadne::RichTextAreaComponent.new(name: :bodytext, sr_label: "Select reply type", attributes: { required: true})) %>
|
28
|
+
<% comment_box.submit { @submit } %>
|
29
|
+
</div>
|
30
|
+
<div class="ariadne-mt-2 ariadne-flex ariadne-justify-end">
|
31
|
+
<%= submit %>
|
32
|
+
</div>
|
33
|
+
<% end %>
|
34
|
+
<% end %>
|
35
|
+
<% end %>
|
8
36
|
<% end %>
|
9
37
|
</div>
|
10
38
|
</div>
|
11
|
-
<%= ariadne_form_with(url: @url, method: @method, classes: @classes, attributes: @attributes) do |comment_box| %>
|
12
|
-
<div class="ariadne-overflow-hidden ariadne-border-x ariadne-border-b ariadne-border-gray-300 ariadne-shadow-sm focus-within:ariadne-border-indigo-500 focus-within:ariadne-ring-1 focus-within:ariadne-ring-indigo-500">
|
13
|
-
<%= hidden_field_tag 'message_public', true %>
|
14
|
-
<%= render(Ariadne::RichTextAreaComponent.new(name: :bodytext, sr_label: "Select reply type", attributes: { required: true})) %>
|
15
|
-
<% comment_box.submit { @submit } %>
|
16
|
-
</div>
|
17
|
-
<div class="ariadne-mt-2 ariadne-flex ariadne-justify-end">
|
18
|
-
<%= submit %>
|
19
|
-
</div>
|
20
|
-
<% end %>
|
21
39
|
</div>
|
22
40
|
<% end %>
|