ariadne_view_components 0.0.88 → 0.0.89
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- 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/behaviors/tooltipable.rb +18 -19
- data/app/components/ariadne/form/base_input_component.rb +6 -0
- data/app/components/ariadne/form/text_field/component.html.erb +2 -2
- data/app/components/ariadne/form/text_field/component.rb +4 -3
- data/app/components/ariadne/form/toggle/component.rb +1 -1
- data/app/components/ariadne/ui/avatar/component.rb +5 -5
- data/app/components/ariadne/ui/button/component.html.erb +1 -1
- data/app/components/ariadne/ui/button/component.rb +25 -1
- data/app/components/ariadne/ui/clipboard_copy/component.ts +6 -6
- data/app/components/ariadne/ui/flash/component.ts +2 -2
- data/app/components/ariadne/ui/pagination/component.html.erb +1 -1
- data/app/components/ariadne/ui/shortcut/component.html.erb +21 -0
- data/app/components/ariadne/ui/shortcut/component.rb +55 -0
- data/app/components/ariadne/ui/shortcut/component.ts +25 -0
- data/app/frontend/controllers/tooltip_controller.ts +73 -0
- data/app/frontend/utils/isMac.ts +3 -0
- data/lib/ariadne/view_components/version.rb +1 -1
- metadata +7 -2
@@ -39,7 +39,7 @@ export default class FlashController extends Controller {
|
|
39
39
|
if (this.hasHiddenClass) {
|
40
40
|
this.element.classList.add(this.hiddenClass)
|
41
41
|
} else {
|
42
|
-
this.element.classList.add('hidden')
|
42
|
+
this.element.classList.add('ariadne-hidden')
|
43
43
|
}
|
44
44
|
|
45
45
|
this.element.remove()
|
@@ -49,7 +49,7 @@ export default class FlashController extends Controller {
|
|
49
49
|
if (this.hasHiddenClass) {
|
50
50
|
this.element.classList.remove(this.hiddenClass)
|
51
51
|
} else {
|
52
|
-
this.element.classList.remove('hidden')
|
52
|
+
this.element.classList.remove('ariadne-hidden')
|
53
53
|
}
|
54
54
|
await enter(this.element)
|
55
55
|
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<span class="ariadne-inline-flex ariadne-items-center ariadne-gap-2">
|
2
|
+
<span><%= text %></span>
|
3
|
+
<kbd data-controller='<%= stimulus_name %>' <%= html_attributes %>>
|
4
|
+
<% keys.each_with_index do |key, index| %>
|
5
|
+
<% if special_keys.include? key.downcase %>
|
6
|
+
<kbd
|
7
|
+
class="<%= html_attrs[:class] %>"
|
8
|
+
data-<%= stimulus_name %>-target="<%= key.downcase %>">
|
9
|
+
<%= key.capitalize %>
|
10
|
+
</kbd>
|
11
|
+
<% elsif key.downcase == 'enter' %>
|
12
|
+
<kbd class="<%= html_attrs[:class] %> !ariadne-font-fallback">↵</kbd>
|
13
|
+
<% else %>
|
14
|
+
<kbd class="<%= html_attrs[:class] %> ariadne-uppercase"><%= key %></kbd>
|
15
|
+
<% end %>
|
16
|
+
<% if index != keys.size - 1 %>
|
17
|
+
<span class="sr-only">+</span>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
</kbd>
|
21
|
+
</span>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Ariadne
|
5
|
+
module UI
|
6
|
+
module Shortcut
|
7
|
+
class Component < Ariadne::BaseComponent
|
8
|
+
SPECIAL_KEYS = ["alt", "shift", "ctrl"]
|
9
|
+
|
10
|
+
option :text, default: proc { "" }
|
11
|
+
option :keys
|
12
|
+
option :size, default: proc { :base }
|
13
|
+
|
14
|
+
def special_keys = SPECIAL_KEYS
|
15
|
+
|
16
|
+
accepts_html_attributes do |html_attrs|
|
17
|
+
html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(:key, size:), html_attrs[:class]].join(" "))
|
18
|
+
end
|
19
|
+
|
20
|
+
style do
|
21
|
+
base do
|
22
|
+
[
|
23
|
+
"ariadne-inline-flex",
|
24
|
+
"ariadne-items-baseline",
|
25
|
+
"ariadne-select-none",
|
26
|
+
"*:ariadne-px-0",
|
27
|
+
]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
style :key do
|
32
|
+
base do
|
33
|
+
["ariadne-font-mono"]
|
34
|
+
end
|
35
|
+
|
36
|
+
variants do
|
37
|
+
size do
|
38
|
+
xs do
|
39
|
+
["ariadne-text-xs", "ariadne-px-1", "ariadne-rounded-sm"]
|
40
|
+
end
|
41
|
+
|
42
|
+
sm do
|
43
|
+
["ariadne-text-sm", "ariadne-px-1.5", "ariadne-rounded"]
|
44
|
+
end
|
45
|
+
|
46
|
+
base do
|
47
|
+
["ariadne-text-base", "ariadne-px-1.5", "ariadne-rounded-md"]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import {controllerFactory} from '@utils/createController'
|
2
|
+
import {isMac} from '@utils/isMac'
|
3
|
+
|
4
|
+
export default class extends controllerFactory()({
|
5
|
+
targets: {
|
6
|
+
alt: HTMLSpanElement,
|
7
|
+
ctrl: HTMLSpanElement,
|
8
|
+
shift: HTMLSpanElement,
|
9
|
+
},
|
10
|
+
}) {
|
11
|
+
private replaceSymbol(targets: HTMLSpanElement[], newValue: string) {
|
12
|
+
for (const el of targets) {
|
13
|
+
el.innerText = newValue
|
14
|
+
el.classList.add('!font-fallback')
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
connect() {
|
19
|
+
if (isMac()) {
|
20
|
+
this.replaceSymbol(this.ctrlTargets, '⌘')
|
21
|
+
this.replaceSymbol(this.altTargets, '⌥')
|
22
|
+
this.replaceSymbol(this.shiftTargets, '⇧')
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import {controllerFactory} from '@utils/createController'
|
2
|
+
import {computePosition, arrow, offset, flip, shift} from '@floating-ui/dom'
|
3
|
+
|
4
|
+
export default class TooltipController extends controllerFactory<HTMLElement>()({
|
5
|
+
targets: {
|
6
|
+
activator: HTMLElement,
|
7
|
+
wrapper: HTMLDivElement,
|
8
|
+
tooltip: HTMLDivElement,
|
9
|
+
arrow: HTMLDivElement,
|
10
|
+
},
|
11
|
+
}) {
|
12
|
+
async update() {
|
13
|
+
computePosition(this.activatorTarget, this.tooltipTarget, {
|
14
|
+
placement: 'top',
|
15
|
+
middleware: [offset(10), flip(), shift({padding: 5}), arrow({element: this.arrowTarget})],
|
16
|
+
// eslint-disable-next-line github/no-then
|
17
|
+
}).then(({x, y, placement, middlewareData}) => {
|
18
|
+
Object.assign(this.tooltipTarget.style, {
|
19
|
+
left: `${x}px`,
|
20
|
+
top: `${y}px`,
|
21
|
+
})
|
22
|
+
|
23
|
+
// Reset any previously set styles on the arrow
|
24
|
+
Object.assign(this.arrowTarget.style, {
|
25
|
+
left: '',
|
26
|
+
top: '',
|
27
|
+
right: '',
|
28
|
+
bottom: '',
|
29
|
+
})
|
30
|
+
|
31
|
+
const {x: arrowX, y: arrowY} = middlewareData.arrow || {}
|
32
|
+
const primaryPlacement = placement.split('-')[0]
|
33
|
+
|
34
|
+
switch (primaryPlacement) {
|
35
|
+
case 'top':
|
36
|
+
Object.assign(this.arrowTarget.style, {
|
37
|
+
left: arrowX ? `${arrowX}px` : '',
|
38
|
+
bottom: '-4px', // Aligns arrow to the bottom edge of the tooltip
|
39
|
+
})
|
40
|
+
break
|
41
|
+
case 'bottom':
|
42
|
+
Object.assign(this.arrowTarget.style, {
|
43
|
+
left: arrowX ? `${arrowX}px` : '',
|
44
|
+
top: '-4px', // Aligns arrow to the top edge of the tooltip
|
45
|
+
})
|
46
|
+
break
|
47
|
+
case 'left':
|
48
|
+
Object.assign(this.arrowTarget.style, {
|
49
|
+
top: arrowY ? `${arrowY}px` : '',
|
50
|
+
right: '-4px', // Aligns arrow to the right edge of the tooltip
|
51
|
+
})
|
52
|
+
break
|
53
|
+
case 'right':
|
54
|
+
Object.assign(this.arrowTarget.style, {
|
55
|
+
top: arrowY ? `${arrowY}px` : '',
|
56
|
+
left: '-4px', // Aligns arrow to the left edge of the tooltip
|
57
|
+
})
|
58
|
+
break
|
59
|
+
}
|
60
|
+
})
|
61
|
+
}
|
62
|
+
|
63
|
+
showTooltip(_event: Event) {
|
64
|
+
this.wrapperTarget.classList.add('ariadne-block')
|
65
|
+
this.wrapperTarget.classList.remove('ariadne-hidden')
|
66
|
+
this.update()
|
67
|
+
}
|
68
|
+
|
69
|
+
hideTooltip(_event: Event) {
|
70
|
+
this.wrapperTarget.classList.add('ariadne-hidden')
|
71
|
+
this.wrapperTarget.classList.remove('ariadne-block')
|
72
|
+
}
|
73
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ariadne_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.89
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tailwind_merge
|
@@ -246,6 +246,9 @@ files:
|
|
246
246
|
- app/components/ariadne/ui/popover/component.html.erb
|
247
247
|
- app/components/ariadne/ui/popover/component.rb
|
248
248
|
- app/components/ariadne/ui/popover/component.ts
|
249
|
+
- app/components/ariadne/ui/shortcut/component.html.erb
|
250
|
+
- app/components/ariadne/ui/shortcut/component.rb
|
251
|
+
- app/components/ariadne/ui/shortcut/component.ts
|
249
252
|
- app/components/ariadne/ui/skeleton/component.html.erb
|
250
253
|
- app/components/ariadne/ui/skeleton/component.rb
|
251
254
|
- app/components/ariadne/ui/stats_panel/component.html.erb
|
@@ -273,10 +276,12 @@ files:
|
|
273
276
|
- app/frontend/ariadne/theme.ts
|
274
277
|
- app/frontend/controllers/form_autosubmit_controller.ts
|
275
278
|
- app/frontend/controllers/form_validity_controller.ts
|
279
|
+
- app/frontend/controllers/tooltip_controller.ts
|
276
280
|
- app/frontend/entrypoints/application.ts
|
277
281
|
- app/frontend/stylesheets/ariadne_view_components.css
|
278
282
|
- app/frontend/stylesheets/scrollbar.css
|
279
283
|
- app/frontend/utils/createController.ts
|
284
|
+
- app/frontend/utils/isMac.ts
|
280
285
|
- app/helpers/ariadne/form_helper.rb
|
281
286
|
- app/lib/ariadne/attributes_helper.rb
|
282
287
|
- app/lib/ariadne/class_name_helper.rb
|