trek 0.1.15 → 0.1.16

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: 6b09da98ecaf56b2d61965f064a51258bc84dced5267977541a810f33416ee2f
4
- data.tar.gz: ad5b3dfc7aaaeef7c8d996fd7ba89ee3f5057c5b93d9c40bcba859c37035b2d0
3
+ metadata.gz: dc939de6d6cc669e8faa27134dd868b9523bafa0236e1cf025673e0abb84d833
4
+ data.tar.gz: 6abb5b7e49ee16d38619f6831d62dda2a05871b09a81f9ea8d44021254a91774
5
5
  SHA512:
6
- metadata.gz: ee62982045c3a349abfe75033fe60731cffb498408af1c6375afde95ef4477a7476f8781c4a206f72d4e04565e886165b652c9da488d0f8c3eb97c0a2c9b256b
7
- data.tar.gz: dcb6b91baad0d783cefcf01c3afb15b54292d105844c291738e2a5972d96905c3c23e6d83435b35a78d0857eb7c12088d01ed21de3a595e8677002c26e214a29
6
+ metadata.gz: 69f4c70a9471eb21966c377cb419e98a314ecac4aeac31dc1f78501e8241450870de557ab77eadc2acc11fa5532193b8db3646406b8dbdee7780355c1e255483
7
+ data.tar.gz: 0c71c307f076c1c601ac37a1b016cc2508fcc78b56fbd114fd7769dce928581ff0daffb22c2f62c011e85fb6a9b8cf6445616c7d47b793538af516f15d01f781
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trek (0.1.15)
4
+ trek (0.1.16)
5
5
  action_policy (~> 0.6)
6
6
  actioncable
7
7
  acts_as_list (~> 1.1)
data/README.md CHANGED
@@ -172,12 +172,16 @@ Then, configure the project to use the local version of Trek (both the gem and t
172
172
 
173
173
  #### Linking to the local gem with bundler
174
174
 
175
- Let's use [Bundler `local` feature](https://bundler.io/v2.4/man/bundle-config.1.html#LOCAL-GIT-REPOS).
175
+ Let's use [Bundler `local` feature](https://bundler.io/v2.7/man/bundle-config.1.html#LOCAL-GIT-REPOS).
176
+
177
+ First, make sure you're pointing to Trek's git repo main branch in your `Gemfile`:
178
+
179
+ gem "trek", git: "git@git.etaminstud.io:etaminstudio/trek.git", branch: :main
176
180
 
177
181
  Navigate to your project, then configure the local version of Trek:
178
182
 
179
183
  cd /local/path/to/yourproject
180
- bundle config local.trek /local/path/to/trek
184
+ bundle config set --local local.trek ~/projects/trek
181
185
 
182
186
  Install the gem and restart the Rails server:
183
187
 
@@ -190,17 +194,21 @@ When you're done, disable the local version:
190
194
 
191
195
  bundle config --delete local.trek
192
196
 
197
+ Don't forget to revert to a released verion in your `Gemfile`:
198
+
199
+ gem "trek", "~> 0.1"
200
+
193
201
  #### Linking to the local NPM package with Yarn
194
202
 
195
203
  Let's use [Yarn `link` feature](https://yarnpkg.com/cli/link).
196
204
 
197
- yarn link /local/path/to/trek
205
+ yarn link ~/projects/trek
198
206
 
199
207
  You don't need to restart the server when you change CSS or JS files in Trek.
200
208
 
201
209
  When you're done, disable the local package:
202
210
 
203
- yarn unlink /local/path/to/trek
211
+ yarn unlink ~/projects/trek
204
212
 
205
213
  ### Publishing a new version
206
214
 
@@ -0,0 +1,46 @@
1
+ .root {
2
+ display: flex;
3
+ margin: 2.4rem 0;
4
+ }
5
+
6
+ .-button-root {
7
+ appearance: none;
8
+ background-color: var(--slate-1);
9
+ border: 1px solid var(--slate-6);
10
+ border-radius: 0;
11
+ color: var(--slate-11);
12
+ cursor: pointer;
13
+ font-size: 1.3rem;
14
+ font-weight: var(--semibold);
15
+ padding: 0.8rem 1.2rem;
16
+ text-decoration: none;
17
+ transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out,
18
+ color 0.2s ease-in-out;
19
+
20
+ &:hover {
21
+ background-color: var(--accent-3);
22
+ border-color: var(--accent-8);
23
+ color: var(--slate-12);
24
+ position: relative;
25
+ }
26
+ }
27
+
28
+ .-button-root + .-button-root {
29
+ margin-left: -1px;
30
+ }
31
+
32
+ .root > .-button-root:first-child {
33
+ border-radius: 0.8rem 0 0 0.8rem;
34
+ }
35
+
36
+ .root > .-button-root:last-child {
37
+ border-radius: 0 0.8rem 0.8rem 0;
38
+ }
39
+
40
+ .-button-root.-button-active {
41
+ background-color: var(--accent-5);
42
+ border-color: var(--accent-8);
43
+ color: var(--accent-12);
44
+ cursor: default;
45
+ position: relative;
46
+ }
@@ -0,0 +1 @@
1
+ import "./button_group_component.css";
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Trek::ButtonGroupComponent < Trek::Component
4
+ renders_many :buttons, "Button"
5
+
6
+ def call
7
+ tag.div(class: root_class) do
8
+ safe_join(buttons)
9
+ end
10
+ end
11
+
12
+ class Button < Trek::Component
13
+ option :active, default: proc { false }
14
+ option :color, optional: true
15
+ option :data, default: proc { {} }
16
+ option :href
17
+ option :text
18
+
19
+ def call
20
+ link_to(
21
+ text,
22
+ href,
23
+ class: classnames
24
+ )
25
+ end
26
+
27
+ def classnames
28
+ class_names_for(
29
+ root_class,
30
+ active:,
31
+ map_args: true
32
+ )
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,120 @@
1
+ /* Use component-local class names and add them to HTML via #class_for(name) helper */
2
+
3
+ .root {
4
+ align-items: center;
5
+ border-top: 1px solid var(--slate-6);
6
+ display: flex;
7
+ gap: 1rem;
8
+ padding: 1.5rem 0;
9
+ position: relative;
10
+ transition: background-color 0.2s ease-in-out;
11
+
12
+ &:only-child {
13
+ border-bottom: 1px solid var(--slate-6);
14
+ }
15
+
16
+ &:hover {
17
+ background-color: var(--slate-2);
18
+ }
19
+ }
20
+
21
+ table .root {
22
+ border: none !important;
23
+ }
24
+
25
+ .content {
26
+ align-items: center;
27
+ color: var(--slate-12);
28
+ flex-grow: 1;
29
+ line-height: 1.25;
30
+ }
31
+
32
+ .image {
33
+ --icon-size: 1.6rem;
34
+
35
+ align-items: center;
36
+ background-color: var(--slate-3);
37
+ border: 1px solid var(--slate-a3);
38
+ border-radius: 0.2rem;
39
+ color: var(--slate-8);
40
+ display: flex;
41
+ aspect-ratio: 16/9;
42
+ justify-content: center;
43
+ margin-right: 2rem;
44
+ overflow: hidden;
45
+ width: 10rem;
46
+
47
+ & img {
48
+ height: 100%;
49
+ object-fit: cover;
50
+ width: 100%;
51
+ }
52
+ }
53
+
54
+ .color-dot {
55
+ background-color: var(--color);
56
+ border-radius: 0.2rem;
57
+ display: inline-block;
58
+ height: 0.8rem;
59
+ margin-right: 1rem;
60
+ width: 0.8rem;
61
+ }
62
+
63
+ .title {
64
+ align-items: center;
65
+ display: flex;
66
+
67
+ &,
68
+ & a {
69
+ color: var(--slate-12);
70
+ }
71
+
72
+ & a {
73
+ text-decoration: none;
74
+ }
75
+
76
+ & a:hover {
77
+ color: var(--accent-10);
78
+ text-decoration: underline;
79
+ }
80
+
81
+ & a::after {
82
+ content: "";
83
+ inset: 0;
84
+ position: absolute;
85
+ }
86
+ }
87
+
88
+ .root > .root {
89
+ margin-left: 3rem;
90
+ }
91
+
92
+ .details {
93
+ color: var(--slate-9);
94
+ display: flex;
95
+ font-size: 1.3rem;
96
+ line-height: 1.2;
97
+ list-style: none;
98
+ margin: 0.2rem 0 0;
99
+ padding: 0;
100
+
101
+ & a {
102
+ color: var(--slate-10);
103
+ position: relative;
104
+ text-decoration: none;
105
+ }
106
+
107
+ & a:hover {
108
+ color: var(--accent-10);
109
+ text-decoration: underline;
110
+ }
111
+
112
+ & code {
113
+ line-height: 1;
114
+ }
115
+ }
116
+
117
+ .detail:not(:last-child)::after {
118
+ content: "•";
119
+ margin: 0 1rem;
120
+ }
@@ -0,0 +1,26 @@
1
+ div(
2
+ class=classes
3
+ data=data.merge(id: item.id)
4
+ id=id
5
+ )
6
+ - if image?
7
+ span(class=class_for("image")) = image
8
+
9
+ div(class=class_for("content"))
10
+ div(class=class_for("title"))
11
+ - if color?
12
+ = color_dot
13
+ - if title?
14
+ = title
15
+ - else
16
+ = item.to_s
17
+
18
+ - if details?
19
+ ul(class=class_for("details"))
20
+ - details.each do |detail|
21
+ - if detail.to_s.present?
22
+ li(class=class_for("detail")) = detail
23
+
24
+ - if status?
25
+ span(class=class_for("status"))
26
+ = status
@@ -0,0 +1 @@
1
+ import "./item_component.css";
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trek
4
+ class Entries::ItemComponent < Trek::Component
5
+ option :action, type: proc(&:to_sym), default: proc { :edit }
6
+ option :classnames, default: proc { {} }
7
+ option :data, default: proc { {} }
8
+ option :id, optional: true
9
+ option :item
10
+
11
+ renders_one :title, ->(href:, &block) { href ? link_to(href, &block) : tag.span(block&.call) }
12
+ renders_one :image, ->(src) { src ? image_tag(src, loading: "lazy") : render(Trek::IconComponent.new("trek/pic")) }
13
+ renders_one :status
14
+ renders_many :buttons, Trek::ButtonComponent
15
+ renders_many :details
16
+
17
+ delegate :allowed_to?, to: :helpers
18
+
19
+ private
20
+
21
+ def classes
22
+ class_names_for(
23
+ root_class,
24
+ (item.status if item.respond_to?(:status)),
25
+ map_args: true,
26
+ **classnames
27
+ )
28
+ end
29
+
30
+ def color?
31
+ item.respond_to?(:color)
32
+ end
33
+
34
+ def color_dot
35
+ tag.span(
36
+ class: class_for("color-dot"),
37
+ style: item.color ? "--color: var(--list-dot-#{item.color}, var(--#{item.color}, #{item.color}))" : "--color: var(--list-dot-empty, darkgrey);"
38
+ )
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,7 @@
1
+ /* Use component-local class names and add them to HTML via #class_for(name) helper */
2
+
3
+ .root {
4
+ margin: 0;
5
+ max-width: 120rem;
6
+ padding: 0;
7
+ }
@@ -0,0 +1,2 @@
1
+ import "./entries_component.css";
2
+ import "../entries/item_component/item_component.js";
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trek
4
+ class EntriesComponent < Trek::Component
5
+ renders_many :items, Trek::Entries::ItemComponent
6
+
7
+ def before_render
8
+ content
9
+ end
10
+
11
+ def call
12
+ tag.div(
13
+ joined_content,
14
+ class: root_class
15
+ )
16
+ end
17
+
18
+ def joined_content
19
+ return t(".empty") if items.empty?
20
+
21
+ safe_join(items)
22
+ end
23
+ end
24
+ end
@@ -32,6 +32,7 @@ en:
32
32
  theme: Theme
33
33
  admin:
34
34
  actions:
35
+ all: All
35
36
  browse: Browse…
36
37
  cancel: Cancel
37
38
  delete: Delete
@@ -201,6 +202,8 @@ en:
201
202
  dialog_component:
202
203
  text: This action cannot be undone.
203
204
  title: Are you sure?
205
+ entries_component:
206
+ empty: No items found
204
207
  form:
205
208
  content_editor_component:
206
209
  blockquote: Quote
@@ -32,6 +32,7 @@ fr:
32
32
  theme: Thème
33
33
  admin:
34
34
  actions:
35
+ all: Tout
35
36
  browse: Parcourir…
36
37
  cancel: Annuler
37
38
  delete: Supprimer
@@ -203,6 +204,8 @@ fr:
203
204
  dialog_component:
204
205
  text: Cette action ne peut pas être annulée.
205
206
  title: Êtes-vous sûr·e ?
207
+ entries_component:
208
+ empty: Aucun élément
206
209
  form:
207
210
  content_editor_component:
208
211
  blockquote: Citation
@@ -69,7 +69,7 @@ module Trek
69
69
  end
70
70
 
71
71
  def add_nbsp_before_chars
72
- regexp = /\b(\p{Zs}?(#{NBSP_BEFORE_CHARS.join("|")}))/
72
+ regexp = /(?<=\S)(\p{Zs}?(#{NBSP_BEFORE_CHARS.join("|")}))/
73
73
  @output.gsub!(regexp, "#{NBSP}\\2")
74
74
  end
75
75
 
data/lib/trek/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Trek
4
- VERSION = "0.1.15"
4
+ VERSION = "0.1.16"
5
5
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etaminstudio/trek",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "A modern CMS for Ruby on Rails",
5
5
  "main": "app/javascript/trek.js",
6
6
  "repository": {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohamed Bengrich
@@ -499,6 +499,9 @@ files:
499
499
  - app/components/trek/button_component.rb
500
500
  - app/components/trek/button_component/button_component.css
501
501
  - app/components/trek/button_component/button_component.js
502
+ - app/components/trek/button_group_component.rb
503
+ - app/components/trek/button_group_component/button_group_component.css
504
+ - app/components/trek/button_group_component/button_group_component.js
502
505
  - app/components/trek/component.rb
503
506
  - app/components/trek/dashboard/section_component.rb
504
507
  - app/components/trek/dashboard/section_component/section_component.css
@@ -512,6 +515,13 @@ files:
512
515
  - app/components/trek/dialog_component/dialog_component.css
513
516
  - app/components/trek/dialog_component/dialog_component.html.slim
514
517
  - app/components/trek/dialog_component/dialog_component.js
518
+ - app/components/trek/entries/item_component.rb
519
+ - app/components/trek/entries/item_component/item_component.css
520
+ - app/components/trek/entries/item_component/item_component.html.slim
521
+ - app/components/trek/entries/item_component/item_component.js
522
+ - app/components/trek/entries_component.rb
523
+ - app/components/trek/entries_component/entries_component.css
524
+ - app/components/trek/entries_component/entries_component.js
515
525
  - app/components/trek/form/actions_component.rb
516
526
  - app/components/trek/form/actions_component/actions_component.css
517
527
  - app/components/trek/form/actions_component/actions_component.html.slim