protos 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f0cbce70d804580aab642e9b099b3eb3de37af48c39314fe396b84db192c60c
4
- data.tar.gz: 21a82750e78f2325286bdbf4c1d741ce9ab8ccb79d946eca324ef128ec1a0604
3
+ metadata.gz: d640442007a4c04a5706286fb3073495ba0bcea036f543c112865d4b8f96646f
4
+ data.tar.gz: 03ee33c002aee6e033ecebda12bab9db1fe74ac2d989213da013a96e79598ceb
5
5
  SHA512:
6
- metadata.gz: 926c96c62de37324ea452b002c533dd61a32c1a5319415d8ef6a4592d1854325e58ad2b93e03d9b7f79c1f9b3ff8ec742f0d9bc4aed1c5caa651b0a747a8bd8d
7
- data.tar.gz: 21ece1afc62a9d5ee521eebbda4347e6111d343965807e80b443b1ea607c43bf6411db97dedb8d395ae332054eaf232932faf1ac850f65e7b5718c8dff01610b
6
+ metadata.gz: 496fc272a6606ab50281cab0cc434bd8c8e8607b6efa976ce2a671b9fdc2ed818c19d41b97c0d9831a835473d37e1846d56ffa0d85791c35d698dedd2521400b
7
+ data.tar.gz: 18a8d1f2f496c47a85a41b84a54c108a889d954c9bead99b1547819b813538d9c8d124ca3e4b4f94bb8ac05ca3121cd56adaf63e79e132c59656bea31473190d
data/README.md CHANGED
@@ -1,9 +1,37 @@
1
1
  # Protos
2
2
 
3
- A UI component library for Phlex using daisyui.
4
-
5
- All components avoid using `Phlex::DeferredRender` so you can reorder components
6
- exactly how you like them.
3
+ A UI component library for [Phlex](https://www.phlex.fun/) using
4
+ [tailwindcss](https://tailwindcss.com/) and
5
+ [daisyUI](https://daisyui.com/).
6
+
7
+ This library avoids re-making Protos components for extremely simple daisyui
8
+ components such as:
9
+
10
+ - Badge
11
+ - Buttons
12
+ - Checkbox
13
+ - File input
14
+ - Indicator
15
+ - Join
16
+ - Kbd
17
+ - Link
18
+ - Loading
19
+ - Mask
20
+ - Progress
21
+ - Radial progress
22
+ - Radio
23
+ - Range
24
+ - Select
25
+ - Skeleton
26
+ - Stack
27
+ - Text input
28
+ - Textarea
29
+ - Toggle
30
+ - Tooltip
31
+
32
+ All components avoid using
33
+ [`Phlex::DeferredRender`](https://www.phlex.fun/#slots)
34
+ so you can reorder components exactly how you like them.
7
35
 
8
36
  Components are easy to style, positioning them is usually done through the
9
37
  `class` option which applies the style to the outer most container of the
@@ -206,6 +234,8 @@ render Protos::Card.new(class: "bg-base-100") do |card|
206
234
  end
207
235
  ```
208
236
 
237
+ ## Building your own components
238
+
209
239
  A good idea would be to encapsulate these proto components with your own
210
240
  components as a wrapper. For example you could use `Proto::List` to create your
211
241
  own list and even use `Phlex::DeferredRender` to make the API more convenient.
@@ -216,20 +246,195 @@ module Ui
216
246
  include Protos::Typography
217
247
  include Phlex::DeferredRender
218
248
 
249
+ option :title, default: -> {}
250
+ option :ordered, default: -> { false }
251
+ option :items, default: -> { [] }, reader: false
252
+ option :actions, default: -> { [] }, reader: false
253
+
219
254
  def template
220
255
  article(**attrs) do
221
256
  header class: css[:header] do
222
257
  h3(size: :md) { title }
223
- nav { render_actions }
258
+ nav(class: css[:actions]) do
259
+ @actions.each do |action|
260
+ render action
261
+ end
262
+ end
263
+ end
264
+
265
+ render Protos::List.new(ordered:, class: css[:list]) do
266
+ @items.each { |item| render item }
267
+ li(&@empty) if @items.empty?
268
+ end
269
+ end
270
+ end
271
+
272
+ def with_item(*, **, &block)
273
+ theme = { container: css[:item] }
274
+ @items << Protos::List::Item.new(*, theme:, **, &block)
275
+ end
276
+
277
+ def with_action(&block)
278
+ @actions << block
279
+ end
280
+
281
+ def with_empty(&block)
282
+ @empty = block
283
+ end
284
+
285
+ private
286
+
287
+ def theme
288
+ {
289
+ container: tokens("space-y-xs"),
290
+ header: tokens("flex", "justify-between", "items-end", "gap-sm"),
291
+ list: tokens("divide-y", "border", "w-full"),
292
+ actions: tokens("space-x-xs"),
293
+ item: tokens("p-sm")
294
+ }
295
+ end
296
+ end
297
+ end
298
+ ```
299
+
300
+ Now the component is specific to our application, and the styles are still
301
+ overridable at all levels:
302
+
303
+ ```ruby
304
+ render Ui::List.new(title: "Project Names") do |list|
305
+ list.with_action { link_to("Add item", "#") }
306
+ list.with_item { "Project 1" }
307
+ list.with_item { "Project 2" }
308
+ list.with_item { "Project 3" }
309
+ end
310
+ ```
311
+
312
+ Or here is another example of a table:
313
+
314
+ ```ruby
315
+ module Ui
316
+ class Table < ApplicationComponent
317
+ include Protos::Typography
318
+ include Phlex::DeferredRender
319
+ include Actionable
320
+
321
+ class Column
322
+ attr_reader :title
323
+
324
+ def initialize(title, &block)
325
+ @title = title
326
+ @block = block
327
+ end
328
+
329
+ def call(item)
330
+ @block.call(item)
331
+ end
332
+ end
333
+
334
+ option :title, default: -> {}
335
+ option :collection, default: -> { [] }, reader: false
336
+ option :columns, default: -> { [] }, reader: false
337
+
338
+ def template
339
+ article(**attrs) do
340
+ header class: css[:header] do
341
+ h3(size: :md) { title } if title.present?
342
+ nav(class: css[:actions]) do
343
+ @actions.each do |action|
344
+ render action
345
+ end
346
+ end
224
347
  end
225
348
 
226
- render Protos::List do |list|
227
- items.each do |item|
228
- render list.item { render item }
349
+ render Protos::Table.new(class: css[:table]) do |table|
350
+ render(table.caption(class: css[:caption]), &@caption) if @caption
351
+ render table.header do
352
+ render table.row do
353
+ @columns.each do |column|
354
+ render table.head do
355
+ plain(column.title)
356
+ end
357
+ end
358
+ end
359
+ end
360
+
361
+ render table.body do
362
+ @collection.each do |item|
363
+ render table.row do
364
+ @columns.each do |column|
365
+ render table.cell do
366
+ column.call(item)
367
+ end
368
+ end
369
+ end
370
+ end
371
+
372
+ if @collection.empty?
373
+ render table.row do
374
+ render table.cell(colspan: @columns.length) do
375
+ @empty&.call
376
+ end
377
+ end
378
+ end
229
379
  end
230
380
  end
231
381
  end
232
382
  end
383
+
384
+ def with_column(...)
385
+ @columns << Column.new(...)
386
+ end
387
+
388
+ def with_empty(&block)
389
+ @empty = block
390
+ end
391
+
392
+ def with_caption(&block)
393
+ @caption = block
394
+ end
395
+
396
+ def with_action(&block)
397
+ @actions << block
398
+ end
399
+
400
+ private
401
+
402
+ def theme
403
+ {
404
+ container: tokens("space-y-sm"),
405
+ header: tokens("flex", "justify-between", "items-end", "gap-sm"),
406
+ table: tokens("border"),
407
+ caption: tokens("text-muted")
408
+ }
409
+ end
410
+ end
411
+ end
412
+ ```
413
+
414
+ Which lets you have a very nice table builder:
415
+
416
+ ```ruby
417
+ collection = [
418
+ {
419
+ name: "John Doe",
420
+ status: "Active",
421
+ location: "New York"
422
+ }
423
+ ]
424
+
425
+ render Ui::Table.new(title: "A table", collection:) do |table|
426
+ table.with_caption { "Users" }
427
+ table.with_action do
428
+ a(href: "#") { "Add new" }
429
+ end
430
+
431
+ table.with_column("Name") { |row| row[:name] }
432
+ table.with_column("Location") { |row| row[:location] }
433
+ table.with_column("Status") do |row|
434
+ span(class: "badge badge-info") { row[:status] }
435
+ end
436
+ table.with_column("Actions") do
437
+ a(href: "#") { "View" }
233
438
  end
234
439
  end
235
440
  ```
data/examples/navbar.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "../lib/protos"
2
4
 
3
5
  class Navbar < Protos::Component
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Breadcrumbs
5
+ class Crumb < Component
6
+ def template(&block)
7
+ li(**attrs, &block)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Breadcrumbs < Component
5
+ def template(&block)
6
+ nav(**attrs) do
7
+ ul(class: css[:list], &block)
8
+ end
9
+ end
10
+
11
+ def crumb(...)
12
+ Crumb.new(...)
13
+ end
14
+
15
+ private
16
+
17
+ def theme
18
+ {
19
+ container: tokens("breadcrumbs")
20
+ }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Carousel
5
+ class Actions < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens(
15
+ "absolute",
16
+ "flex",
17
+ "justify-between",
18
+ "transform",
19
+ "-translate-y-1/2",
20
+ "left-sm",
21
+ "right-sm",
22
+ "top-1/2"
23
+ )
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Carousel
5
+ class Item < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("carousel-item")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Carousel < Component
5
+ option :vertical, type: Types::Bool, default: -> { false }
6
+ option :snap_to,
7
+ default: -> { :none },
8
+ reader: false,
9
+ type: Types::Coercible::Symbol.enum(
10
+ :none,
11
+ :center,
12
+ :end
13
+ )
14
+
15
+ def template(&block)
16
+ div(**attrs, &block)
17
+ end
18
+
19
+ def item(...)
20
+ Item.new(...)
21
+ end
22
+
23
+ def actions(...)
24
+ Actions.new(...)
25
+ end
26
+
27
+ private
28
+
29
+ def snap_to
30
+ {
31
+ none: "",
32
+ center: "carousel-center",
33
+ end: "carousel-end"
34
+ }.fetch(@snap_to)
35
+ end
36
+
37
+ def theme
38
+ {
39
+ container: tokens(
40
+ "carousel",
41
+ snap_to,
42
+ vertical: "carousel-vertical"
43
+ )
44
+ }
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class ChatBubble
5
+ class Content < Component
6
+ option :type,
7
+ default: -> { :none },
8
+ reader: false,
9
+ type: Types::Coercible::Symbol.enum(
10
+ :none,
11
+ :primary,
12
+ :secondary,
13
+ :accent,
14
+ :info,
15
+ :success,
16
+ :warning,
17
+ :error
18
+ )
19
+
20
+ def template(&block)
21
+ div(**attrs, &block)
22
+ end
23
+
24
+ private
25
+
26
+ def type
27
+ {
28
+ none: "",
29
+ primary: "chat-bubble-primary",
30
+ secondary: "chat-bubble-secondary",
31
+ accent: "chat-bubble-accent",
32
+ info: "chat-bubble-info",
33
+ success: "chat-bubble-success",
34
+ warning: "chat-bubble-warning",
35
+ error: "chat-bubble-error"
36
+ }.fetch(@type)
37
+ end
38
+
39
+ def theme
40
+ {
41
+ container: tokens("chat-bubble", type)
42
+ }
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class ChatBubble
5
+ class Footer < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("chat-footer")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class ChatBubble
5
+ class Header < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("chat-header")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class ChatBubble
5
+ class Image < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("chat-image")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class ChatBubble < Component
5
+ option :align,
6
+ default: -> { :start },
7
+ reader: false,
8
+ type: Types::Coercible::Symbol.enum(
9
+ :start,
10
+ :end
11
+ )
12
+
13
+ def template(&block)
14
+ div(**attrs, &block)
15
+ end
16
+
17
+ def image(...)
18
+ Image.new(...)
19
+ end
20
+
21
+ def header(...)
22
+ Header.new(...)
23
+ end
24
+
25
+ def footer(...)
26
+ Footer.new(...)
27
+ end
28
+
29
+ def content(...)
30
+ Content.new(...)
31
+ end
32
+
33
+ private
34
+
35
+ def align
36
+ {
37
+ start: "chat-start",
38
+ end: "chat-end"
39
+ }.fetch(@align)
40
+ end
41
+
42
+ def theme
43
+ {
44
+ container: tokens("chat", align)
45
+ }
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Hero
5
+ class Content < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("hero-content")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Hero
5
+ class Overlay < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("hero-overlay")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Hero < Component
5
+ def template(&block)
6
+ div(**attrs, &block)
7
+ end
8
+
9
+ def content(...)
10
+ Content.new(...)
11
+ end
12
+
13
+ def overlay(...)
14
+ Overlay.new(...)
15
+ end
16
+
17
+ private
18
+
19
+ def theme
20
+ {
21
+ container: tokens("hero")
22
+ }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Stats
5
+ class Actions < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("stat-actions")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Stats
5
+ class Description < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("stat-desc")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Stats
5
+ class Figure < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("stat-figure")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Stats
5
+ class Stat < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("stat")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Stats
5
+ class Title < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("stat-title")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Stats
5
+ class Value < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("stat-value")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Stats < Component
5
+ def template(&block)
6
+ div(**attrs, &block)
7
+ end
8
+
9
+ private
10
+
11
+ def theme
12
+ {
13
+ container: tokens("stats")
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Swap
5
+ class Off < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("swap-off")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Swap
5
+ class On < Component
6
+ def template(&block)
7
+ div(**attrs, &block)
8
+ end
9
+
10
+ private
11
+
12
+ def theme
13
+ {
14
+ container: tokens("swap-on")
15
+ }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Swap < Component
5
+ def template
6
+ label(**attrs) do
7
+ input(type: :checkbox)
8
+ yield if block_given?
9
+ end
10
+ end
11
+
12
+ def on(...)
13
+ On.new(...)
14
+ end
15
+
16
+ def off(...)
17
+ Off.new(...)
18
+ end
19
+
20
+ private
21
+
22
+ def theme
23
+ {
24
+ container: tokens("swap")
25
+ }
26
+ end
27
+ end
28
+ end
@@ -3,9 +3,39 @@
3
3
  module Protos
4
4
  class Table
5
5
  class Cell < Component
6
+ option :align,
7
+ type: Types::Coercible::Symbol.enum(:left, :center, :right),
8
+ default: -> {
9
+ :left
10
+ }
11
+
6
12
  def template(&block)
7
13
  td(**attrs, &block)
8
14
  end
15
+
16
+ private
17
+
18
+ def left?
19
+ align == :left
20
+ end
21
+
22
+ def center?
23
+ align == :center
24
+ end
25
+
26
+ def right?
27
+ align == :right
28
+ end
29
+
30
+ def theme
31
+ {
32
+ container: tokens(
33
+ left?: "text-left",
34
+ right?: "text-right",
35
+ center?: "text-center"
36
+ )
37
+ }
38
+ end
9
39
  end
10
40
  end
11
41
  end
@@ -3,9 +3,39 @@
3
3
  module Protos
4
4
  class Table
5
5
  class Head < Component
6
+ option :align,
7
+ type: Types::Coercible::Symbol.enum(:left, :center, :right),
8
+ default: -> {
9
+ :left
10
+ }
11
+
6
12
  def template(&block)
7
13
  th(**attrs, &block)
8
14
  end
15
+
16
+ private
17
+
18
+ def left?
19
+ align == :left
20
+ end
21
+
22
+ def center?
23
+ align == :center
24
+ end
25
+
26
+ def right?
27
+ align == :right
28
+ end
29
+
30
+ def theme
31
+ {
32
+ container: tokens(
33
+ left?: "text-left",
34
+ right?: "text-right",
35
+ center?: "text-center"
36
+ )
37
+ }
38
+ end
9
39
  end
10
40
  end
11
41
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Tabs
5
+ class Tab < Component
6
+ param :id
7
+ option :label
8
+ option :active, default: false
9
+ option :disabled, default: false
10
+
11
+ def template(&block)
12
+ input(
13
+ type: :radio,
14
+ class: css[:input],
15
+ name: id,
16
+ role: :tab,
17
+ aria_label: label
18
+ )
19
+ div(**attrs, &block)
20
+ end
21
+
22
+ private
23
+
24
+ def default_attrs
25
+ {
26
+ role: :tabpanel
27
+ }
28
+ end
29
+
30
+ def theme
31
+ {
32
+ container: tokens("tab-content"),
33
+ input: tokens(
34
+ "tab",
35
+ disabled: "tab-disabled",
36
+ active: "tab-active"
37
+ )
38
+ }
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Tabs < Component
5
+ option :type,
6
+ type: Types::Coercible::Symbol.enum(
7
+ :default,
8
+ :boxed,
9
+ :bordered,
10
+ :lifted
11
+ ),
12
+ default: -> { :default },
13
+ reader: false
14
+ option :size,
15
+ type: Types::Coercible::Symbol.enum(
16
+ :xs,
17
+ :sm,
18
+ :md,
19
+ :lg
20
+ ),
21
+ default: -> { :md },
22
+ reader: false
23
+
24
+ def template(&block)
25
+ div(**attrs, &block)
26
+ end
27
+
28
+ def tab(...)
29
+ Tab.new(...)
30
+ end
31
+
32
+ private
33
+
34
+ def size
35
+ {
36
+ xs: "tabs-xs",
37
+ sm: "tabs-sm",
38
+ md: "tabs-md",
39
+ lg: "tabs-lg"
40
+ }.fetch(@size)
41
+ end
42
+
43
+ def type
44
+ {
45
+ bordered: "tabs-bordered",
46
+ boxed: "tabs-boxed",
47
+ lifted: "tabs-lifted",
48
+ default: ""
49
+ }.fetch(@type)
50
+ end
51
+
52
+ def default_attrs
53
+ {
54
+ role: :tablist
55
+ }
56
+ end
57
+
58
+ def theme
59
+ {
60
+ container: tokens("tabs", size, type)
61
+ }
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Toast
5
+ class CloseButton < Component
6
+ def template(&block)
7
+ form(method: :dialog, class: css[:form]) do
8
+ button(
9
+ autofocus: true,
10
+ formmethod: :dialog,
11
+ **attrs,
12
+ &block
13
+ )
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Protos
4
+ class Toast < Component
5
+ Positions = Types::Symbol.enum(
6
+ :start,
7
+ :center,
8
+ :end,
9
+ :top,
10
+ :middle,
11
+ :bottom
12
+ )
13
+
14
+ option :position, type: Positions, default: -> { :end }
15
+
16
+ def template(&block)
17
+ dialog(**attrs, &block)
18
+ end
19
+
20
+ def close_button(...)
21
+ CloseButton.new(...)
22
+ end
23
+
24
+ private
25
+
26
+ def default_attrs
27
+ {
28
+ open: true
29
+ }
30
+ end
31
+
32
+ def theme
33
+ {
34
+ container: tokens(
35
+ "toast",
36
+ "toast-end",
37
+ "[&:not([open])]:hidden"
38
+ )
39
+ }
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Protos
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/protos.rb CHANGED
@@ -27,12 +27,25 @@ module Protos
27
27
 
28
28
  require_relative "protos/avatar"
29
29
 
30
+ require_relative "protos/breadcrumbs"
31
+ require_relative "protos/breadcrumbs/crumb"
32
+
30
33
  require_relative "protos/card"
31
34
  require_relative "protos/card/body"
32
35
  require_relative "protos/card/title"
33
36
  require_relative "protos/card/actions"
34
37
  require_relative "protos/card/image"
35
38
 
39
+ require_relative "protos/carousel"
40
+ require_relative "protos/carousel/item"
41
+ require_relative "protos/carousel/actions"
42
+
43
+ require_relative "protos/chat_bubble"
44
+ require_relative "protos/chat_bubble/content"
45
+ require_relative "protos/chat_bubble/image"
46
+ require_relative "protos/chat_bubble/header"
47
+ require_relative "protos/chat_bubble/footer"
48
+
36
49
  require_relative "protos/collapse"
37
50
  require_relative "protos/collapse/title"
38
51
  require_relative "protos/collapse/content"
@@ -59,6 +72,10 @@ module Protos
59
72
  require_relative "protos/dropdown/menu"
60
73
  require_relative "protos/dropdown/trigger"
61
74
 
75
+ require_relative "protos/hero"
76
+ require_relative "protos/hero/content"
77
+ require_relative "protos/hero/overlay"
78
+
62
79
  require_relative "protos/list"
63
80
  require_relative "protos/list/item"
64
81
 
@@ -71,6 +88,21 @@ module Protos
71
88
  require_relative "protos/popover/trigger"
72
89
  require_relative "protos/popover/content"
73
90
 
91
+ require_relative "protos/stats"
92
+ require_relative "protos/stats/actions"
93
+ require_relative "protos/stats/description"
94
+ require_relative "protos/stats/figure"
95
+ require_relative "protos/stats/stat"
96
+ require_relative "protos/stats/title"
97
+ require_relative "protos/stats/value"
98
+
99
+ require_relative "protos/swap"
100
+ require_relative "protos/swap/on"
101
+ require_relative "protos/swap/off"
102
+
103
+ require_relative "protos/tabs"
104
+ require_relative "protos/tabs/tab"
105
+
74
106
  require_relative "protos/table"
75
107
  require_relative "protos/table/caption"
76
108
  require_relative "protos/table/header"
@@ -80,6 +112,9 @@ module Protos
80
112
  require_relative "protos/table/row"
81
113
  require_relative "protos/table/cell"
82
114
 
115
+ require_relative "protos/toast"
116
+ require_relative "protos/toast/close_button"
117
+
83
118
  require_relative "protos/timeline"
84
119
  require_relative "protos/timeline/item"
85
120
  require_relative "protos/timeline/left"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nolan J Tait
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-04 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-core
@@ -88,11 +88,21 @@ files:
88
88
  - lib/protos/alert/icon.rb
89
89
  - lib/protos/attributes.rb
90
90
  - lib/protos/avatar.rb
91
+ - lib/protos/breadcrumbs.rb
92
+ - lib/protos/breadcrumbs/crumb.rb
91
93
  - lib/protos/card.rb
92
94
  - lib/protos/card/actions.rb
93
95
  - lib/protos/card/body.rb
94
96
  - lib/protos/card/image.rb
95
97
  - lib/protos/card/title.rb
98
+ - lib/protos/carousel.rb
99
+ - lib/protos/carousel/actions.rb
100
+ - lib/protos/carousel/item.rb
101
+ - lib/protos/chat_bubble.rb
102
+ - lib/protos/chat_bubble/content.rb
103
+ - lib/protos/chat_bubble/footer.rb
104
+ - lib/protos/chat_bubble/header.rb
105
+ - lib/protos/chat_bubble/image.rb
96
106
  - lib/protos/collapse.rb
97
107
  - lib/protos/collapse/content.rb
98
108
  - lib/protos/collapse/title.rb
@@ -116,6 +126,9 @@ files:
116
126
  - lib/protos/dropdown/menu.rb
117
127
  - lib/protos/dropdown/trigger.rb
118
128
  - lib/protos/engine.rb
129
+ - lib/protos/hero.rb
130
+ - lib/protos/hero/content.rb
131
+ - lib/protos/hero/overlay.rb
119
132
  - lib/protos/list.rb
120
133
  - lib/protos/list/item.rb
121
134
  - lib/protos/modal.rb
@@ -125,6 +138,16 @@ files:
125
138
  - lib/protos/popover.rb
126
139
  - lib/protos/popover/content.rb
127
140
  - lib/protos/popover/trigger.rb
141
+ - lib/protos/stats.rb
142
+ - lib/protos/stats/actions.rb
143
+ - lib/protos/stats/description.rb
144
+ - lib/protos/stats/figure.rb
145
+ - lib/protos/stats/stat.rb
146
+ - lib/protos/stats/title.rb
147
+ - lib/protos/stats/value.rb
148
+ - lib/protos/swap.rb
149
+ - lib/protos/swap/off.rb
150
+ - lib/protos/swap/on.rb
128
151
  - lib/protos/table.rb
129
152
  - lib/protos/table/body.rb
130
153
  - lib/protos/table/caption.rb
@@ -133,12 +156,16 @@ files:
133
156
  - lib/protos/table/head.rb
134
157
  - lib/protos/table/header.rb
135
158
  - lib/protos/table/row.rb
159
+ - lib/protos/tabs.rb
160
+ - lib/protos/tabs/tab.rb
136
161
  - lib/protos/theme.rb
137
162
  - lib/protos/timeline.rb
138
163
  - lib/protos/timeline/center.rb
139
164
  - lib/protos/timeline/item.rb
140
165
  - lib/protos/timeline/left.rb
141
166
  - lib/protos/timeline/right.rb
167
+ - lib/protos/toast.rb
168
+ - lib/protos/toast/close_button.rb
142
169
  - lib/protos/token_list.rb
143
170
  - lib/protos/types.rb
144
171
  - lib/protos/typography.rb