atomic_view 0.1.3 → 0.1.4
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/config/atomic_view_manifest.js +0 -1
- data/app/assets/tailwind/atomic_view/engine.css +78 -14
- data/lib/atomic_view/components/button_component.rb +31 -1
- data/lib/atomic_view/components/check_box_component.rb +1 -1
- data/lib/atomic_view/components/collection_select_component.rb +3 -3
- data/lib/atomic_view/components/date_field_component.rb +3 -3
- data/lib/atomic_view/components/field_component.erb +2 -2
- data/lib/atomic_view/components/field_component.rb +4 -4
- data/lib/atomic_view/components/label_component.rb +1 -1
- data/lib/atomic_view/components/select_component.rb +3 -3
- data/lib/atomic_view/components/submit_component.rb +38 -1
- data/lib/atomic_view/version.rb +1 -1
- metadata +2 -3
- data/config/tailwind.config.js +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 710cd3a75e70122c759e7af3db35eadde82192422faa14e70bbe9cd3272769fb
|
4
|
+
data.tar.gz: 3301a83351ddf672355f276e44cf651747aa9c3f30a9295781ffbeb1a4a1005a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44ec8863dd5c0d48190c459d308f77fcfd4f8bdfba92ab005e8116b794a8bd53037d3bce843e97427d2b8a7ddcc0e5359270b85c664674c2f5ed3b72d30de7ba
|
7
|
+
data.tar.gz: c4c9d5c05cc01ebdebbf0e4a77a7f26f6fba58302afb97660d60a9e58607b55fedf78f1e58e77b3c645864eb7b3dfdfb02a31e592671b5225a07fc49075eca13
|
@@ -1,25 +1,89 @@
|
|
1
1
|
@import "tailwindcss" source(none);
|
2
2
|
@source "../../javascripts/**/*.js";
|
3
3
|
@source "../../../views/**/*.{erb}";
|
4
|
-
@source "../../../../lib/atomic_view
|
4
|
+
@source "../../../../lib/atomic_view/components/**/*.{erb,rb}";
|
5
|
+
@source "../../../../previews/**/*.{erb,rb}";
|
5
6
|
|
6
7
|
@plugin "@tailwindcss/forms";
|
7
8
|
@plugin "@tailwindcss/typography";
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
@theme {
|
11
|
+
--color-surface: var(--color-white);
|
12
|
+
--color-offset: var(--color-gray-50);
|
13
|
+
--color-backdrop: oklch(0 0 0 / 0.5);
|
14
|
+
|
15
|
+
--color-border: var(--color-gray-200);
|
16
|
+
--color-input: var(--color-gray-200);
|
17
|
+
--color-ring: var(--color-gray-950);
|
18
|
+
|
19
|
+
--color-primary: var(--color-neutral-800);
|
20
|
+
--color-primary-foreground: var(--color-white);
|
21
|
+
|
22
|
+
--color-secondary: var(--color-neutral-200);
|
23
|
+
--color-secondary-foreground: var(--color-neutral-950);
|
24
|
+
|
25
|
+
--color-muted: var(--color-neutral-200);
|
26
|
+
--color-muted-foreground: var(--color-neutral-800);
|
27
|
+
|
28
|
+
--color-accent: var(--color-green-800);
|
29
|
+
--color-accent-foreground: var(--color-green-50);
|
30
|
+
|
31
|
+
--color-destructive: var(--color-red-800);
|
32
|
+
--color-destructive-foreground: var(--color-red-50);
|
33
|
+
|
34
|
+
--color-disabled: var(--color-gray-50);
|
35
|
+
--color-disabled-foreground: var(--color-zinc-500);
|
36
|
+
--color-disabled-ring: var(--color-zinc-200);
|
37
|
+
|
38
|
+
--color-error: var(--color-red-900);
|
39
|
+
--color-error-ring: var(--color-red-300);
|
40
|
+
--color-error-placeholder: var(--color-red-300);
|
41
|
+
--color-error-focus-ring: var(--color-red-500);
|
42
|
+
|
43
|
+
--color-placeholder: var(--color-zinc-500);
|
44
|
+
--color-focus-ring: var(--color-neutral-700);
|
45
|
+
}
|
46
|
+
|
47
|
+
.dark {
|
48
|
+
--color-surface: var(--color-neutral-950);
|
49
|
+
--color-offset: var(--color-neutral-900);
|
50
|
+
--color-backdrop: oklch(0 0 0 / 0.5);
|
51
|
+
|
52
|
+
--color-border: var(--color-white);
|
53
|
+
--color-input: var(--color-white);
|
54
|
+
--color-ring: var(--color-white);
|
55
|
+
|
56
|
+
--color-primary: var(--color-white);
|
57
|
+
--color-primary-foreground: var(--color-neutral-800);
|
58
|
+
|
59
|
+
--color-secondary: var(--color-neutral-800);
|
60
|
+
--color-secondary-foreground: var(--color-neutral-100);
|
61
|
+
|
62
|
+
--color-muted: var(--color-neutral-800);
|
63
|
+
--color-muted-foreground: var(--color-neutral-200);
|
64
|
+
|
65
|
+
--color-accent: var(--color-green-50);
|
66
|
+
--color-accent-foreground: var(--color-green-800);
|
67
|
+
|
68
|
+
--color-destructive: var(--color-red-800);
|
69
|
+
--color-destructive-foreground: var(--color-red-50);
|
70
|
+
|
71
|
+
--color-disabled: var(--color-neutral-800);
|
72
|
+
--color-disabled-foreground: var(--color-neutral-400);
|
73
|
+
--color-disabled-ring: var(--color-neutral-600);
|
74
|
+
|
75
|
+
--color-error: var(--color-red-100);
|
76
|
+
--color-error-ring: var(--color-red-400);
|
77
|
+
--color-error-placeholder: var(--color-red-400);
|
78
|
+
--color-error-focus-ring: var(--color-red-500);
|
79
|
+
|
80
|
+
--color-placeholder: var(--color-neutral-400);
|
81
|
+
--color-focus-ring: var(--color-white/20);
|
82
|
+
}
|
13
83
|
|
14
|
-
If we ever want to remove these styles, we need to add an explicit border
|
15
|
-
color utility to any element that depends on these defaults.
|
16
|
-
*/
|
17
84
|
@layer base {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
::backdrop,
|
22
|
-
::file-selector-button {
|
23
|
-
border-color: var(--color-gray-200, currentColor);
|
85
|
+
button:not(:disabled),
|
86
|
+
[role="button"]:not(:disabled) {
|
87
|
+
cursor: pointer;
|
24
88
|
}
|
25
89
|
}
|
@@ -4,23 +4,53 @@ module AtomicView
|
|
4
4
|
module Components
|
5
5
|
# Button
|
6
6
|
class ButtonComponent < ViewComponent::Form::ButtonComponent
|
7
|
-
attr_reader :label
|
7
|
+
attr_reader :label, :variant, :size
|
8
8
|
|
9
9
|
def initialize(form, label_or_options = nil, options = nil)
|
10
10
|
super
|
11
11
|
|
12
12
|
if label_or_options.is_a?(String)
|
13
13
|
@label = label_or_options
|
14
|
+
@options ||= {}
|
15
|
+
elsif label_or_options.is_a?(Hash)
|
16
|
+
@options = label_or_options
|
14
17
|
end
|
18
|
+
|
19
|
+
@variant = @options.delete(:variant) || :primary
|
15
20
|
end
|
16
21
|
|
17
22
|
def call
|
23
|
+
@options[:class] = class_names(base_classes, variant_classes, @options[:class])
|
24
|
+
|
18
25
|
if content?
|
19
26
|
content_tag(:button, @options) { content }
|
20
27
|
else
|
21
28
|
content_tag(:button, label, @options)
|
22
29
|
end
|
23
30
|
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def base_classes
|
35
|
+
"h-8 rounded-md px-3 inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]"
|
36
|
+
end
|
37
|
+
|
38
|
+
def variant_classes
|
39
|
+
case variant
|
40
|
+
when :primary
|
41
|
+
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90"
|
42
|
+
when :secondary
|
43
|
+
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80"
|
44
|
+
when :destructive
|
45
|
+
"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20"
|
46
|
+
when :muted
|
47
|
+
"bg-transparent text-muted-foreground hover:bg-muted"
|
48
|
+
when :link
|
49
|
+
"text-primary underline-offset-4 hover:underline"
|
50
|
+
else
|
51
|
+
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90"
|
52
|
+
end
|
53
|
+
end
|
24
54
|
end
|
25
55
|
end
|
26
56
|
end
|
@@ -2,7 +2,7 @@ module AtomicView
|
|
2
2
|
module Components
|
3
3
|
class CheckBoxComponent < ViewComponent::Form::CheckBoxComponent
|
4
4
|
def html_class
|
5
|
-
"
|
5
|
+
"peer border-input dark:bg-input/30 checked:bg-primary checked:text-primary-foreground dark:checked:bg-primary checked:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
@@ -4,9 +4,9 @@ module AtomicView
|
|
4
4
|
def html_class
|
5
5
|
class_names(
|
6
6
|
*%W[block w-full h-9 min-w-0 flex-1 rounded-md border-0 py-1 text-sm shadow-xs ring-1],
|
7
|
-
"disabled:cursor-not-allowed disabled:bg-
|
8
|
-
"bg-transparent dark:bg-white/5 text-
|
9
|
-
"text-
|
7
|
+
"disabled:cursor-not-allowed disabled:bg-disabled disabled:text-disabled-foreground disabled:ring-disabled-ring",
|
8
|
+
"bg-transparent dark:bg-white/5 text-primary ring-ring/10 dark:ring-white/10 placeholder:text-placeholder dark:text-white focus:ring-focus-ring focus:border-ring/20 dark:focus:ring-focus-ring",
|
9
|
+
"text-error ring-error-ring placeholder:text-error-placeholder focus:ring-error-focus-ring" => method_errors?
|
10
10
|
)
|
11
11
|
end
|
12
12
|
end
|
@@ -5,9 +5,9 @@ module AtomicView
|
|
5
5
|
class_names(
|
6
6
|
class_names(
|
7
7
|
*%W[block w-full h-9 min-w-0 flex-1 rounded-sm border-0 py-1 text-sm shadow-xs ring-1],
|
8
|
-
"disabled:cursor-not-allowed disabled:bg-
|
9
|
-
"bg-transparent dark:bg-white/5 text-
|
10
|
-
"text-
|
8
|
+
"disabled:cursor-not-allowed disabled:bg-disabled disabled:text-disabled-foreground disabled:ring-disabled-ring",
|
9
|
+
"bg-transparent dark:bg-white/5 text-primary ring-ring/10 dark:ring-white/10 placeholder:text-placeholder dark:text-white focus:ring-focus-ring focus:border-ring/20 dark:focus:ring-focus-ring",
|
10
|
+
"text-error ring-error-ring placeholder:text-error-placeholder focus:ring-error-focus-ring" => method_errors?
|
11
11
|
),
|
12
12
|
options[:class]
|
13
13
|
)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= content_tag :div, class: container_html_class do %>
|
2
2
|
<% if left_section? %>
|
3
3
|
<% if left_section_addon? %>
|
4
|
-
<span class="inline-flex items-center rounded-l-lg bg-transparent dark:bg-white/5 ring-1 ring-
|
4
|
+
<span class="inline-flex items-center rounded-l-lg bg-transparent dark:bg-white/5 ring-1 ring-ring/10 dark:ring-white/10 px-3 text-primary dark:text-white sm:text-sm"><%= left_section %></span>
|
5
5
|
<% elsif left_section_interaction? %>
|
6
6
|
<%= left_section %>
|
7
7
|
<% else %>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<%= tag_klass.new(@object_name, @method_name, @view_context, @options).render %>
|
14
14
|
<% if right_section? %>
|
15
15
|
<% if right_section_addon? %>
|
16
|
-
<span class="inline-flex items-center rounded-r-lg bg-transparent dark:bg-white/5 ring-1 ring-
|
16
|
+
<span class="inline-flex items-center rounded-r-lg bg-transparent dark:bg-white/5 ring-1 ring-ring/10 dark:ring-white/10 px-3 text-primary dark:text-white sm:text-sm"><%= right_section %></span>
|
17
17
|
<% elsif right_section_interaction? %>
|
18
18
|
<%= right_section %>
|
19
19
|
<% else %>
|
@@ -11,13 +11,13 @@ module AtomicView
|
|
11
11
|
def html_class
|
12
12
|
class_names(
|
13
13
|
"block w-full appearance-none h-9 min-w-0 z-10 flex-1 rounded-lg border-0 py-1 text-base shadow-xs ring-1",
|
14
|
-
"disabled:cursor-not-allowed disabled:bg-
|
15
|
-
"bg-transparent dark:bg-white/5 text-
|
14
|
+
"disabled:cursor-not-allowed disabled:bg-disabled disabled:text-disabled-foreground disabled:ring-disabled-ring",
|
15
|
+
"bg-transparent dark:bg-white/5 text-primary ring-ring/10 dark:ring-white/10 placeholder:text-placeholder dark:text-white focus:ring-focus-ring focus:border-ring/20 dark:focus:ring-focus-ring",
|
16
16
|
"pl-10" => left_section? && !(left_section_addon? || left_section_interaction?),
|
17
17
|
"pr-10" => right_section? && !(right_section_addon? || right_section_interaction?),
|
18
18
|
"shadow-none rounded-none rounded-r-lg" => left_section_addon? || left_section_interaction?,
|
19
19
|
"shadow-none rounded-none rounded-l-lg" => right_section_addon? || right_section_interaction?,
|
20
|
-
"text-
|
20
|
+
"text-error ring-error-ring placeholder:text-error-placeholder focus:ring-error-focus-ring" => method_errors?
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
@@ -46,7 +46,7 @@ module AtomicView
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def right_section
|
49
|
-
options[:right_section] || method_errors? && raw(icon("exclamation-circle", variant: :mini, options: {class: "size-5 text-
|
49
|
+
options[:right_section] || method_errors? && raw(icon("exclamation-circle", variant: :mini, options: {class: "size-5 text-destructive"}))
|
50
50
|
end
|
51
51
|
|
52
52
|
def right_section?
|
@@ -5,9 +5,9 @@ module AtomicView
|
|
5
5
|
class_names(
|
6
6
|
class_names(
|
7
7
|
*%W[block w-full h-9 min-w-0 flex-1 rounded-md border-0 py-1 text-sm shadow-xs ring-1],
|
8
|
-
"disabled:cursor-not-allowed disabled:bg-
|
9
|
-
"bg-transparent dark:bg-white/5 text-
|
10
|
-
"text-
|
8
|
+
"disabled:cursor-not-allowed disabled:bg-disabled disabled:text-disabled-foreground disabled:ring-disabled-ring",
|
9
|
+
"bg-transparent dark:bg-white/5 text-primary ring-ring/10 dark:ring-white/10 placeholder:text-placeholder dark:text-white focus:ring-focus-ring focus:border-ring/20 dark:focus:ring-focus-ring",
|
10
|
+
"text-error ring-error-ring placeholder:text-error-placeholder focus:ring-error-focus-ring" => method_errors?
|
11
11
|
),
|
12
12
|
options[:class]
|
13
13
|
)
|
@@ -1,8 +1,45 @@
|
|
1
1
|
module AtomicView
|
2
2
|
module Components
|
3
3
|
class SubmitComponent < ViewComponent::Form::SubmitComponent
|
4
|
+
attr_reader :variant
|
5
|
+
|
6
|
+
def initialize(form, value_or_options = nil, options = nil)
|
7
|
+
super
|
8
|
+
|
9
|
+
if value_or_options.is_a?(Hash)
|
10
|
+
@options = value_or_options
|
11
|
+
else
|
12
|
+
@options ||= {}
|
13
|
+
end
|
14
|
+
|
15
|
+
@variant = @options.delete(:variant) || :primary
|
16
|
+
end
|
17
|
+
|
4
18
|
def html_class
|
5
|
-
|
19
|
+
class_names(base_classes, variant_classes, @options[:class])
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def base_classes
|
25
|
+
"h-8 rounded-md px-3 inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]"
|
26
|
+
end
|
27
|
+
|
28
|
+
def variant_classes
|
29
|
+
case variant
|
30
|
+
when :primary
|
31
|
+
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90"
|
32
|
+
when :secondary
|
33
|
+
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80"
|
34
|
+
when :destructive
|
35
|
+
"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20"
|
36
|
+
when :muted
|
37
|
+
"bg-transparent text-muted-foreground hover:bg-muted"
|
38
|
+
when :link
|
39
|
+
"text-primary underline-offset-4 hover:underline"
|
40
|
+
else
|
41
|
+
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90"
|
42
|
+
end
|
6
43
|
end
|
7
44
|
end
|
8
45
|
end
|
data/lib/atomic_view/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atomic_view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Warrington
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-09-
|
11
|
+
date: 2025-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -136,7 +136,6 @@ files:
|
|
136
136
|
- app/views/layouts/atomic_view/lookbook.html.erb
|
137
137
|
- config/importmap.rb
|
138
138
|
- config/routes.rb
|
139
|
-
- config/tailwind.config.js
|
140
139
|
- lib/atomic_view.rb
|
141
140
|
- lib/atomic_view/component.rb
|
142
141
|
- lib/atomic_view/components/button_component.rb
|
data/config/tailwind.config.js
DELETED