coveragebook_components 0.7.10 → 0.8.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/build/coco/app.css +1065 -148
  3. data/app/assets/build/coco/app.js +255 -47
  4. data/app/assets/build/coco/book.css +26 -0
  5. data/app/assets/css/app/tippy.css +4 -0
  6. data/app/components/coco/app/blocks/header/header.css +43 -0
  7. data/app/components/coco/app/blocks/header/header.html.erb +30 -0
  8. data/app/components/coco/app/blocks/header/header.js +11 -0
  9. data/app/components/coco/app/blocks/header/header.rb +35 -0
  10. data/app/components/coco/app/blocks/nav_drawer/nav_drawer.css +48 -3
  11. data/app/components/coco/app/blocks/nav_drawer/nav_drawer.html.erb +14 -6
  12. data/app/components/coco/app/blocks/nav_drawer/nav_drawer.js +18 -1
  13. data/app/components/coco/app/blocks/nav_drawer/nav_drawer.rb +26 -1
  14. data/app/components/coco/app/blocks/sidebar_nav/sidebar_nav.css +104 -0
  15. data/app/components/coco/app/blocks/sidebar_nav/sidebar_nav.html.erb +42 -0
  16. data/app/components/coco/app/blocks/sidebar_nav/sidebar_nav.js +28 -0
  17. data/app/components/coco/app/blocks/sidebar_nav/sidebar_nav.rb +28 -0
  18. data/app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.css +165 -0
  19. data/app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.html.erb +43 -0
  20. data/app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.js +41 -0
  21. data/app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.rb +98 -0
  22. data/app/components/coco/app/elements/alert/alert.css +65 -18
  23. data/app/components/coco/app/elements/alert/alert.html.erb +4 -4
  24. data/app/components/coco/app/elements/alert/alert.js +4 -3
  25. data/app/components/coco/app/elements/alert/alert.rb +10 -0
  26. data/app/components/coco/app/elements/button/button.css +58 -0
  27. data/app/components/coco/app/elements/button/button.rb +1 -1
  28. data/app/components/coco/app/elements/button_group/button_group.rb +4 -0
  29. data/app/components/coco/app/elements/color_picker/color_picker.rb +1 -1
  30. data/app/components/coco/app/elements/menu/menu.css +1 -0
  31. data/app/components/coco/app/elements/menu/menu.html.erb +1 -1
  32. data/app/components/coco/app/elements/menu/menu.rb +2 -1
  33. data/app/components/coco/app/elements/menu_items/user_profile/user_profile.css +22 -0
  34. data/app/components/coco/app/elements/menu_items/user_profile/user_profile.html.erb +17 -0
  35. data/app/components/coco/app/elements/menu_items/user_profile/user_profile.rb +20 -0
  36. data/app/components/coco/app/elements/notice/notice.css +4 -0
  37. data/app/components/coco/app/elements/snackbar/snackbar.css +8 -1
  38. data/app/components/coco/app/elements/snackbar/snackbar.rb +2 -2
  39. data/app/components/coco/app/elements/system_banner/system_banner.html.erb +2 -1
  40. data/app/components/coco/app/elements/system_banner/system_banner.js +35 -2
  41. data/app/components/coco/app/elements/system_banner/system_banner.rb +47 -3
  42. data/app/components/coco/app/layouts/application/application.css +104 -4
  43. data/app/components/coco/app/layouts/application/application.html.erb +28 -7
  44. data/app/components/coco/app/layouts/application/application.js +16 -0
  45. data/app/components/coco/app/layouts/application/application.rb +11 -3
  46. data/app/components/coco/base/avatar/avatar.css +25 -0
  47. data/app/components/coco/base/avatar/avatar.rb +20 -0
  48. data/app/components/coco/base/modal/modal.html.erb +1 -1
  49. data/app/components/coco/concerns/accepts_tag_attributes.rb +6 -2
  50. data/app/components/coco/concerns/acts_as_button_group.rb +5 -0
  51. data/app/helpers/coco/app_helper.rb +16 -0
  52. data/app/helpers/coco/base_helper.rb +4 -0
  53. data/config/tokens.cjs +4 -1
  54. data/lib/coco.rb +1 -1
  55. metadata +22 -10
  56. data/app/components/coco/app/blocks/banner/banner.css +0 -5
  57. data/app/components/coco/app/blocks/banner/banner.rb +0 -8
  58. data/app/components/coco/app/blocks/nav_bar/nav_bar.css +0 -51
  59. data/app/components/coco/app/blocks/nav_bar/nav_bar.html.erb +0 -23
  60. data/app/components/coco/app/blocks/nav_bar/nav_bar.js +0 -31
  61. data/app/components/coco/app/blocks/nav_bar/nav_bar.rb +0 -19
@@ -1,9 +1,109 @@
1
1
  @layer components {
2
- [data-coco][data-component="app-application-layout"] {
3
- @apply grid grid-rows-[min-content_1fr] h-screen w-screen overflow-hidden;
2
+ [data-coco][data-component="application-layout"] {
3
+ @apply grid overflow-hidden absolute inset-0 w-screen;
4
+ height: var(--app-height);
4
5
 
5
- .app-main {
6
- @apply overflow-auto;
6
+ grid-template-areas: "body";
7
+ grid-template-rows: 1fr;
8
+ grid-template-columns: 1fr;
9
+
10
+ &.with-header {
11
+ grid-template-areas: "header" "body";
12
+ grid-template-rows: min-content 1fr;
13
+
14
+ &.with-banner {
15
+ grid-template-areas: "header" "body" "banner";
16
+ grid-template-rows: min-content 1fr min-content;
17
+
18
+ &.with-sidebar-nav {
19
+ grid-template-areas: "header" "body" "banner" "sidebar";
20
+ grid-template-rows: min-content 1fr min-content min-content;
21
+ }
22
+ }
23
+
24
+ &:not(.with-banner) {
25
+ &.with-sidebar-nav {
26
+ grid-template-areas: "header" "body" "sidebar";
27
+ grid-template-rows: min-content 1fr min-content;
28
+ }
29
+ }
30
+ }
31
+
32
+ &.with-sidebar-nav {
33
+ --snackbar-bottom-offset: theme(spacing.16);
34
+ }
35
+
36
+ &:not(.with-header).with-banner {
37
+ grid-template-areas: "body" "banner";
38
+ grid-template-rows: 1fr min-content;
39
+ }
40
+
41
+ .layout-banner {
42
+ @apply w-screen z-10;
43
+ grid-area: banner;
44
+ height: min-content;
45
+ }
46
+
47
+ .layout-header {
48
+ @apply w-screen z-10;
49
+ grid-area: header;
50
+ height: min-content;
51
+ }
52
+
53
+ .layout-body {
54
+ @apply relative z-0 h-full overflow-y-auto scroll-smooth;
55
+ grid-area: body;
56
+ }
57
+
58
+ .layout-sidebar-nav {
59
+ @apply scroll-smooth;
60
+ scrollbar-width: none;
61
+ grid-area: sidebar;
62
+ height: min-content;
63
+
64
+ &::-webkit-scrollbar {
65
+ display: none;
66
+ }
67
+ }
68
+
69
+ @media screen(sm) {
70
+ .layout-sidebar-nav {
71
+ @apply h-full overflow-auto;
72
+ width: min-content;
73
+
74
+ > * {
75
+ @apply h-full;
76
+ }
77
+ }
78
+
79
+ grid-template-areas: "body";
80
+ grid-template-rows: 1fr;
81
+
82
+ &.with-sidebar-nav {
83
+ --snackbar-bottom-offset: theme(spacing.10);
84
+ }
85
+
86
+ &.with-header {
87
+ &.with-banner {
88
+ grid-template-areas: "banner" "header" "body";
89
+ grid-template-rows: min-content min-content 1fr;
90
+ grid-template-columns: 1fr;
91
+
92
+ &.with-sidebar-nav {
93
+ grid-template-areas: "banner banner" "header header" "sidebar body";
94
+ grid-template-rows: min-content min-content 1fr;
95
+ grid-template-columns: min-content 1fr;
96
+ }
97
+ }
98
+
99
+ &:not(.with-banner) {
100
+ &.with-sidebar-nav {
101
+ grid-template-areas: "header header" "sidebar body";
102
+ grid-template-rows: min-content 1fr;
103
+ grid-template-columns: min-content 1fr;
104
+ }
105
+ }
106
+ }
7
107
  }
8
108
  }
9
109
  }
@@ -1,9 +1,30 @@
1
- <%= render component_tag do %>
2
- <header class="app-header">
3
- <%= banner %>
4
- <%= navbar %>
5
- </header>
6
- <main class="app-main">
1
+ <%= render component_tag(
2
+ x: {
3
+ data: x_data("appLayout", banner: banner? && banner_content?),
4
+ ":class": "{'with-banner': banner}"
5
+ },
6
+ class: {
7
+ "with-sidebar-nav": sidebar_nav?,
8
+ "with-banner": banner? && banner_content?,
9
+ "with-header": header?
10
+ }) do %>
11
+ <% if banner? && banner_content? %>
12
+ <div class="layout-banner" data-role="app-banner" role="banner" @banner:dismiss="hideBanner">
13
+ <%= banner %>
14
+ </div>
15
+ <% end %>
16
+ <% if header? %>
17
+ <div class="layout-header" data-role="app-header">
18
+ <%= header %>
19
+ </div>
20
+ <% end %>
21
+ <% if sidebar_nav? %>
22
+ <div class="layout-sidebar-nav" data-role="app-sidebar-nav">
23
+ <%= sidebar_nav %>
24
+ </div>
25
+ <% end %>
26
+ <div class="layout-body" data-role="app-body">
7
27
  <%= content %>
8
- </main>
28
+ </div>
29
+ <%= flashes %>
9
30
  <% end %>
@@ -0,0 +1,16 @@
1
+ import { CocoComponent } from "@js/coco";
2
+
3
+ export default CocoComponent("appLayout", (opts) => {
4
+ return {
5
+ banner: false,
6
+
7
+ init() {
8
+ this.banner = opts.banner;
9
+ },
10
+
11
+ hideBanner() {
12
+ this.banner = false;
13
+ this.$el.remove();
14
+ },
15
+ };
16
+ });
@@ -2,10 +2,18 @@ module Coco
2
2
  module App
3
3
  module Layouts
4
4
  class Application < Coco::Component
5
- renders_one :banner, Blocks::Banner
6
- renders_one :navbar, Blocks::NavBar
5
+ include Concerns::AcceptsOptions
7
6
 
8
- component_name :app_application_layout
7
+ renders_one :flashes
8
+ renders_one :banner
9
+ renders_one :header
10
+ renders_one :sidebar_nav
11
+
12
+ component_name :application_layout
13
+
14
+ def banner_content?
15
+ banner.to_s.strip != ""
16
+ end
9
17
  end
10
18
  end
11
19
  end
@@ -0,0 +1,25 @@
1
+ @layer components {
2
+ [data-coco][data-component="avatar"] {
3
+ @apply block rounded-full overflow-hidden flex-none;
4
+
5
+ img {
6
+ @apply w-full rounded-full;
7
+ }
8
+
9
+ &[data-size="sm"] {
10
+ @apply w-5 h-5;
11
+ }
12
+
13
+ &[data-size="md"] {
14
+ @apply w-6 h-6;
15
+ }
16
+
17
+ &[data-size="lg"] {
18
+ @apply w-7 h-7;
19
+ }
20
+
21
+ &[data-size="xl"] {
22
+ @apply w-8 h-8;
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,20 @@
1
+ module Coco
2
+ class Avatar < Coco::Component
3
+ include Concerns::AcceptsOptions
4
+
5
+ accepts_option :size, from: %i[sm md lg xl], default: :md
6
+
7
+ attr_reader :src, :name
8
+
9
+ def initialize(src:, name: nil, **)
10
+ @src = src
11
+ @name = name
12
+ end
13
+
14
+ def call
15
+ render component_tag do
16
+ tag.img src: src, alt: name
17
+ end
18
+ end
19
+ end
20
+ end
@@ -12,7 +12,7 @@
12
12
  },
13
13
  ) do %>
14
14
  <div class="modal-overlay" x-bind="overlay"></div>
15
- <div class="modal-container" x-bind="container" x-ref="container">
15
+ <div class="modal-container" x-bind="container" x-ref="container">
16
16
  <div class="modal-content" x-trap.noscroll.inert.noreturn="open">
17
17
  <%= modal_content %>
18
18
  </div>
@@ -11,8 +11,8 @@ module Coco
11
11
  @_tag_name
12
12
  end
13
13
 
14
- def tag_attr(*attr_names)
15
- tag_attr_names.push(*attr_names)
14
+ def tag_attr(*)
15
+ tag_attr_names.push(*)
16
16
  end
17
17
 
18
18
  def tag_attr_names
@@ -48,6 +48,10 @@ module Coco
48
48
  tag_attrs.key?(attr_name)
49
49
  end
50
50
 
51
+ def tag_attr(attr_name, fallback = nil)
52
+ tag_attrs.fetch(attr_name, fallback)
53
+ end
54
+
51
55
  private
52
56
 
53
57
  def process_tag_attrs(args)
@@ -14,6 +14,7 @@ module Coco
14
14
 
15
15
  included do
16
16
  renders_many :items, types: {
17
+ noop: -> {},
17
18
  divider: ->(**kwargs) { tag.div(class: "divider") },
18
19
  button: ->(*args, **kwargs, &block) { coco_button(*args, **button_kwargs(kwargs, :button), &block) },
19
20
  menu_button: ->(*args, **kwargs, &block) { instantiate_button(:menu, *args, **kwargs, &block) },
@@ -35,6 +36,10 @@ module Coco
35
36
  component
36
37
  end
37
38
 
39
+ def init_button_group
40
+ with_item_noop
41
+ end
42
+
38
43
  def with_divider(...)
39
44
  with_item_divider(...)
40
45
  end
@@ -95,5 +95,21 @@ module Coco
95
95
  def coco_fields(**, &block)
96
96
  fields(**, builder: Coco::AppFormBuilder, &block)
97
97
  end
98
+
99
+ def coco_layout(name, **, &block)
100
+ render coco_component("app/layouts/#{name}", **), &block
101
+ end
102
+
103
+ def coco_app_header(*, **, &block)
104
+ render Coco::App::Blocks::Header.new(*, **), &block
105
+ end
106
+
107
+ def coco_sidebar_nav(*, **, &block)
108
+ render Coco::App::Blocks::SidebarNav.new(*, **), &block
109
+ end
110
+
111
+ def coco_menu_item(type, **, &block)
112
+ render coco_component("app/elements/menu_items/#{type}", **), &block
113
+ end
98
114
  end
99
115
  end
@@ -12,6 +12,10 @@ module Coco
12
12
  render Coco::Image.new(src: src, **)
13
13
  end
14
14
 
15
+ def coco_avatar(src, name = nil, **)
16
+ render Coco::Avatar.new(src: src, name: name, **)
17
+ end
18
+
15
19
  def coco_icon(icon_name = nil, **, &block)
16
20
  render Coco::Icon.new(name: icon_name, **), &block
17
21
  end
data/config/tokens.cjs CHANGED
@@ -90,6 +90,9 @@ const colorAliases = {
90
90
  ...colors.blue,
91
91
  },
92
92
  background: {
93
+ header: {
94
+ DEFAULT: "#427484",
95
+ },
93
96
  light: {
94
97
  1: colors.white,
95
98
  2: colors.gray[50],
@@ -169,7 +172,7 @@ const screens = {
169
172
  xl: "1200px",
170
173
  "2xl": "1400px",
171
174
  max: "1800px",
172
- "small-landscape": { raw: "(max-height: 760px) and (min-width: 576px)" },
175
+ letterbox: { raw: "(max-height: 760px) and (min-width: 576px)" },
173
176
  print: { raw: "print" }, // Note: PDFs are rendered at a viewport width of 1280px
174
177
  };
175
178
 
data/lib/coco.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Coco
2
- VERSION = "0.7.10"
2
+ VERSION = "0.8.0.beta.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coveragebook_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.10
4
+ version: 0.8.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Perkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-19 00:00:00.000000000 Z
11
+ date: 2023-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -1348,16 +1348,22 @@ files:
1348
1348
  - app/assets/js/libs/alpine/utils/tippy_modifiers.js
1349
1349
  - app/assets/js/libs/tippy/index.js
1350
1350
  - app/assets/js/libs/tippy/plugins/hide_on_esc.js
1351
- - app/components/coco/app/blocks/banner/banner.css
1352
- - app/components/coco/app/blocks/banner/banner.rb
1353
- - app/components/coco/app/blocks/nav_bar/nav_bar.css
1354
- - app/components/coco/app/blocks/nav_bar/nav_bar.html.erb
1355
- - app/components/coco/app/blocks/nav_bar/nav_bar.js
1356
- - app/components/coco/app/blocks/nav_bar/nav_bar.rb
1351
+ - app/components/coco/app/blocks/header/header.css
1352
+ - app/components/coco/app/blocks/header/header.html.erb
1353
+ - app/components/coco/app/blocks/header/header.js
1354
+ - app/components/coco/app/blocks/header/header.rb
1357
1355
  - app/components/coco/app/blocks/nav_drawer/nav_drawer.css
1358
1356
  - app/components/coco/app/blocks/nav_drawer/nav_drawer.html.erb
1359
1357
  - app/components/coco/app/blocks/nav_drawer/nav_drawer.js
1360
1358
  - app/components/coco/app/blocks/nav_drawer/nav_drawer.rb
1359
+ - app/components/coco/app/blocks/sidebar_nav/sidebar_nav.css
1360
+ - app/components/coco/app/blocks/sidebar_nav/sidebar_nav.html.erb
1361
+ - app/components/coco/app/blocks/sidebar_nav/sidebar_nav.js
1362
+ - app/components/coco/app/blocks/sidebar_nav/sidebar_nav.rb
1363
+ - app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.css
1364
+ - app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.html.erb
1365
+ - app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.js
1366
+ - app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.rb
1361
1367
  - app/components/coco/app/blocks/slat/slat.css
1362
1368
  - app/components/coco/app/blocks/slat/slat.rb
1363
1369
  - app/components/coco/app/blocks/slide_editor/slide_editor.css
@@ -1410,6 +1416,9 @@ files:
1410
1416
  - app/components/coco/app/elements/menu_button/menu_button.html.erb
1411
1417
  - app/components/coco/app/elements/menu_button/menu_button.js
1412
1418
  - app/components/coco/app/elements/menu_button/menu_button.rb
1419
+ - app/components/coco/app/elements/menu_items/user_profile/user_profile.css
1420
+ - app/components/coco/app/elements/menu_items/user_profile/user_profile.html.erb
1421
+ - app/components/coco/app/elements/menu_items/user_profile/user_profile.rb
1413
1422
  - app/components/coco/app/elements/notice/notice.css
1414
1423
  - app/components/coco/app/elements/notice/notice.html.erb
1415
1424
  - app/components/coco/app/elements/notice/notice.js
@@ -1469,7 +1478,10 @@ files:
1469
1478
  - app/components/coco/app/fields/weekday_select_component.rb
1470
1479
  - app/components/coco/app/layouts/application/application.css
1471
1480
  - app/components/coco/app/layouts/application/application.html.erb
1481
+ - app/components/coco/app/layouts/application/application.js
1472
1482
  - app/components/coco/app/layouts/application/application.rb
1483
+ - app/components/coco/base/avatar/avatar.css
1484
+ - app/components/coco/base/avatar/avatar.rb
1473
1485
  - app/components/coco/base/button/button.css
1474
1486
  - app/components/coco/base/button/button.html.erb
1475
1487
  - app/components/coco/base/button/button.js
@@ -1593,9 +1605,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1593
1605
  version: 3.2.0
1594
1606
  required_rubygems_version: !ruby/object:Gem::Requirement
1595
1607
  requirements:
1596
- - - ">="
1608
+ - - ">"
1597
1609
  - !ruby/object:Gem::Version
1598
- version: '0'
1610
+ version: 1.3.1
1599
1611
  requirements: []
1600
1612
  rubygems_version: 3.4.19
1601
1613
  signing_key:
@@ -1,5 +0,0 @@
1
- @layer components {
2
- [data-coco][data-component="app-banner"] {
3
- @apply px-app py-2 text-center;
4
- }
5
- }
@@ -1,8 +0,0 @@
1
- module Coco
2
- module App
3
- module Blocks
4
- class Banner < Coco::Component
5
- end
6
- end
7
- end
8
- end
@@ -1,51 +0,0 @@
1
- @layer components {
2
- [data-coco][data-component="app-navbar"] {
3
- @apply @container;
4
-
5
- .nav-content {
6
- @apply h-11 @lg:h-14 flex items-center bg-teal-700 px-app;
7
- }
8
-
9
- .nav-logo {
10
- @apply flex-none mr-8;
11
- }
12
-
13
- .nav-logo-small {
14
- @apply h-6 @lg:hidden;
15
- }
16
-
17
- .nav-logo-full {
18
- @apply hidden @lg:block h-7;
19
- }
20
-
21
- .nav-links {
22
- @apply flex items-center w-full overflow-hidden;
23
- }
24
-
25
- .nav-link-group {
26
- @apply flex items-center gap-x-6;
27
-
28
- .nav-button {
29
- > .button-inner {
30
- @apply whitespace-nowrap text-white gap-2 text-label-sm @5xl:text-label-md py-2;
31
- }
32
-
33
- [data-component="icon"] {
34
- @apply w-4 h-4;
35
- }
36
- }
37
- }
38
-
39
- .nav-secondary {
40
- @apply ml-auto;
41
- }
42
-
43
- .nav-mobile-controls {
44
- @apply flex items-center ml-auto text-white -mr-2;
45
-
46
- [data-component="app-button"] {
47
- @apply p-2;
48
- }
49
- }
50
- }
51
- }
@@ -1,23 +0,0 @@
1
- <%= render component_tag(x: {data: "appNavBar"}) do %>
2
- <div class="nav-content">
3
- <div class="nav-logo">
4
- <%= image_tag asset_url("coco/img/coveragebook-logomark-white.svg"),
5
- alt: "CoverageBook logomark",
6
- class: "nav-logo-small" %>
7
- <%= image_tag asset_url("coco/img/coveragebook-landscape-white.svg"),
8
- alt: "CoverageBook full logo",
9
- class: "nav-logo-full" %>
10
- </div>
11
- <div class="nav-links" x-ref="links">
12
- <div class="nav-link-group nav-primary" x-ref="primaryLinks" x-show="!mobile" x-cloak>
13
- <%= safe_join(primary_buttons) %>
14
- </div>
15
- <div class="nav-link-group nav-secondary" x-ref="secondaryLinks" x-show="!mobile" x-cloak>
16
- <%= safe_join(secondary_buttons) %>
17
- </div>
18
- <div class="nav-mobile-controls" x-show="mobile" x-cloak>
19
- <%= coco_button(icon: :menu, theme: nil) %>
20
- </div>
21
- </div>
22
- </div>
23
- <% end %>
@@ -1,31 +0,0 @@
1
- import { CocoComponent } from "@js/coco";
2
- import { getHiddenElementDimensions as getSize } from "@helpers/dom";
3
- import tokens from "@config/tokens.cjs";
4
-
5
- export default CocoComponent("appNavBar", () => {
6
- const mobileMaxWidth = parseInt(tokens.app.screens.md, 10);
7
- return {
8
- mobile: true,
9
- init() {
10
- const sizeObserver = new ResizeObserver(
11
- Alpine.throttle((entries) => {
12
- this.$nextTick(() => {
13
- const navWidth = entries[0].contentRect.width;
14
- const linksWidth = this.$refs.links.offsetWidth;
15
- const primaryWidth = getSize(this.$refs.primaryLinks, "flex").width;
16
- const secondaryWidth = getSize(
17
- this.$refs.secondaryLinks,
18
- "flex"
19
- ).width;
20
- const difference = linksWidth - primaryWidth - secondaryWidth;
21
-
22
- this.mobile =
23
- navWidth < mobileMaxWidth || this.mobudifference <= 50;
24
- });
25
- }, 20)
26
- );
27
-
28
- sizeObserver.observe(this.$root);
29
- },
30
- };
31
- });
@@ -1,19 +0,0 @@
1
- module Coco
2
- module App
3
- module Blocks
4
- class NavBar < Coco::Component
5
- include Coco::AppHelper
6
-
7
- component_name :app_navbar
8
-
9
- renders_many :primary_buttons, ->(*a, **k, &b) { nav_button(*a, **k, &b) }
10
-
11
- renders_many :secondary_buttons, ->(*a, **k, &b) { nav_button(*a, **k, &b) }
12
-
13
- def nav_button(*args, **kwargs, &block)
14
- coco_button(*args, **kwargs, theme: nil, size: nil, class: "nav-button", &block)
15
- end
16
- end
17
- end
18
- end
19
- end