essence 0.3.1 → 1.0.0
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/lib/essence/cli/add.rb +32 -19
- data/lib/essence/cli/install.rb +4 -14
- data/lib/essence/cli/version.rb +1 -1
- data/lib/essence/cli.rb +0 -53
- data/lib/essence/client.rb +22 -0
- data/lib/essence/configuration.rb +10 -2
- data/lib/essence/definitions.rb +89 -0
- data/lib/essence/version.rb +1 -1
- data/lib/essence.rb +42 -13
- metadata +11 -39
- data/essence/stimulus/tabs_controller.js +0 -40
- data/lib/essence/components/accordion.rb +0 -36
- data/lib/essence/components/avatar.rb +0 -31
- data/lib/essence/components/badge.rb +0 -35
- data/lib/essence/components/button.rb +0 -45
- data/lib/essence/components/dialog.rb +0 -21
- data/lib/essence/components/dropdown.rb +0 -18
- data/lib/essence/components/essence.rb +0 -16
- data/lib/essence/components/link.rb +0 -20
- data/lib/essence/components/row.rb +0 -28
- data/lib/essence/components/skeleton.rb +0 -24
- data/lib/essence/components/tabs.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59a6855e33ea69ca4e5f1847a24cbaf2db2991629c7f3d1cfd25a8c693fd0b2a
|
4
|
+
data.tar.gz: 2dc9d1a6297541a6db339295a8526b2572ad27b4d1d2b1e1b908f25002ee2020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1667d7a7bf8a96772fc0de875a7db052962d17f7dd7d09bdbb958616124796fd398044bca76753a9ff4797232a40c0aa2e99ac1503e683047e07919354377515
|
7
|
+
data.tar.gz: 411224f217aa0e5a0731e5137054650827b6a002a878afcac158725d03cdf2dc954789a449eaf56e18afd94d9231222d9782c337df655d018b6299f42728ba78
|
data/lib/essence/cli/add.rb
CHANGED
@@ -1,34 +1,47 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'fileutils'
|
4
|
+
|
3
5
|
module Essence
|
4
6
|
module CLI
|
5
7
|
class Add < Dry::CLI::Command
|
6
|
-
desc "Add an Essence component
|
7
|
-
argument :
|
8
|
+
desc "Add an Essence UI component"
|
9
|
+
argument :component, required: true, desc: "Component name"
|
8
10
|
example Essence.component_names
|
9
11
|
|
10
12
|
def call(*args)
|
11
|
-
|
12
|
-
key = component_name.to_sym
|
13
|
-
has_stimulus_controller = Essence.components[key][:stimulus] || false
|
13
|
+
puts "[Essence UI] Fetching..."
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
slug = args[0][:component].to_sym
|
16
|
+
specification = ::Essence::Client.new.get_component(slug:)
|
17
|
+
return puts "[Essence UI] Component not found. Stopping" if specification == ""
|
17
18
|
|
18
|
-
if has_stimulus_controller
|
19
|
-
Essence::CLI::Commands.copy_controller(component_name:)
|
20
|
-
puts "> [Stimulus] #{Essence::CLI::Commands::STIMULUS_CONTROLLERS_DESTINATION_DIR.join("#{component_name}_controller.js")}"
|
21
|
-
end
|
22
19
|
|
23
|
-
|
24
|
-
Essence
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
20
|
+
files = specification.dig("files")
|
21
|
+
return puts "[Essence UI] Something went wrong. Stopping" unless files
|
22
|
+
|
23
|
+
files.each{ |data| insert_file(slug:, data:) }
|
24
|
+
puts "[Essence UI] #{specification.dig("title")} has been successfully added!"
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def insert_file(slug:, data:)
|
30
|
+
destination_path = build_destination_path(kind: data["kind"], slug:)
|
31
|
+
::FileUtils.mkdir_p(destination_path.dirname)
|
32
|
+
::File.write(destination_path, data.dig("content"))
|
33
|
+
puts "[Essence UI] Adding #{destination_path}"
|
34
|
+
end
|
30
35
|
|
31
|
-
|
36
|
+
def build_destination_path(kind:, slug:)
|
37
|
+
case kind
|
38
|
+
when "phlex"
|
39
|
+
::Essence.configuration.phlex_components_dir.join("#{slug}.rb")
|
40
|
+
when "stimulus"
|
41
|
+
::Essence.configuration.stimulus_controllers_dir.join("#{slug}_controller.rb")
|
42
|
+
else
|
43
|
+
nil
|
44
|
+
end
|
32
45
|
end
|
33
46
|
end
|
34
47
|
end
|
data/lib/essence/cli/install.rb
CHANGED
@@ -7,21 +7,11 @@ module Essence
|
|
7
7
|
BASE_DEFINITION_PREFIX = "class Essence::Essence"
|
8
8
|
PHLEX_BASE_DEFINITION_PREFIX = "class Components::Essence"
|
9
9
|
|
10
|
-
desc "Install Essence to your
|
10
|
+
desc "Install Essence UI to your codebase"
|
11
11
|
def call(*)
|
12
|
-
puts "
|
13
|
-
|
14
|
-
Essence
|
15
|
-
Essence::CLI::Commands.replace_component_contents(
|
16
|
-
component_name: BASE_COMPONENT_NAME,
|
17
|
-
from: BASE_DEFINITION_PREFIX,
|
18
|
-
to: PHLEX_BASE_DEFINITION_PREFIX
|
19
|
-
)
|
20
|
-
# Essence::CLI::Commands.rename_component_file(
|
21
|
-
# from: Essence::CLI::Commands::DESTINATION_DIR.join("#{BASE_COMPONENT_NAME}.rb"),
|
22
|
-
# to: Essence::CLI::Commands::DESTINATION_DIR.join("essence.rb")
|
23
|
-
# )
|
24
|
-
puts "> Essence has been successfully installed!"
|
12
|
+
puts "[Essence UI] Installing..."
|
13
|
+
::Essence::CLI::Add.new.call(*[{component: "essence"}])
|
14
|
+
puts "[Essence UI] Done!"
|
25
15
|
end
|
26
16
|
end
|
27
17
|
end
|
data/lib/essence/cli/version.rb
CHANGED
data/lib/essence/cli.rb
CHANGED
@@ -16,62 +16,9 @@ module Essence
|
|
16
16
|
module Commands
|
17
17
|
extend Dry::CLI::Registry
|
18
18
|
|
19
|
-
# Constants
|
20
|
-
STIMULUS_CONTROLLERS_DIR = Pathname.new(::Essence.root_path).join("essence/stimulus")
|
21
|
-
STIMULUS_CONTROLLERS_DESTINATION_DIR = Pathname.new(File.expand_path(Dir.pwd)).join(::Essence.configuration.stimulus_controller_path)
|
22
|
-
|
23
|
-
COMPONENTS_DIR = Pathname.new(File.expand_path("components", __dir__))
|
24
|
-
DESTINATION_DIR = Pathname.new(File.expand_path(Dir.pwd)).join(::Essence.configuration.phlex_components_path)
|
25
|
-
|
26
|
-
COMPONENT_DEFINITION_PREFIX = "class Essence::"
|
27
|
-
COMPONENT_DEFINITION_SUFFIX = "< Essence::Essence"
|
28
|
-
PHLEX_COMPONENT_DEFINITION_PREFIX = "class Components::"
|
29
|
-
PHLEX_COMPONENT_DEFINITION_SUFFIX = "< Components::Essence"
|
30
|
-
|
31
|
-
# Registering commands
|
32
19
|
register "add", Add, aliases: ["a", "generate", "g"]
|
33
20
|
register "install", Install, aliases: ["i"]
|
34
21
|
register "version", Version, aliases: ["v", "-v", "--version"]
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
# UTILITIES
|
39
|
-
# PHLEX COMPONENTS
|
40
|
-
def self.copy_component(component_name:)
|
41
|
-
source_path = COMPONENTS_DIR.join("#{component_name}.rb")
|
42
|
-
destination_path = DESTINATION_DIR.join("#{component_name}.rb")
|
43
|
-
|
44
|
-
FileUtils.mkdir_p(DESTINATION_DIR)
|
45
|
-
FileUtils.copy(source_path, destination_path)
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.replace_component_contents(
|
49
|
-
component_name:,
|
50
|
-
from: COMPONENT_DEFINITION_PREFIX,
|
51
|
-
to: PHLEX_COMPONENT_DEFINITION_PREFIX
|
52
|
-
)
|
53
|
-
component_file = DESTINATION_DIR.join("#{component_name}.rb")
|
54
|
-
return unless File.exist?(component_file)
|
55
|
-
|
56
|
-
replaced_content = File.read(component_file).gsub(from, to)
|
57
|
-
File.write(component_file, replaced_content)
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.rename_component_file(from:, to:)
|
61
|
-
return if from.nil? || to.nil?
|
62
|
-
return unless File.exist?(from)
|
63
|
-
|
64
|
-
FileUtils.mv(from, to)
|
65
|
-
end
|
66
|
-
|
67
|
-
# STIMULUS CONTROLLERS
|
68
|
-
def self.copy_controller(component_name:)
|
69
|
-
source_path = STIMULUS_CONTROLLERS_DIR.join("#{component_name}_controller.js")
|
70
|
-
destination_path = STIMULUS_CONTROLLERS_DESTINATION_DIR.join("#{component_name}_controller.js")
|
71
|
-
|
72
|
-
FileUtils.mkdir_p(STIMULUS_CONTROLLERS_DESTINATION_DIR)
|
73
|
-
FileUtils.copy(source_path, destination_path)
|
74
|
-
end
|
75
22
|
end
|
76
23
|
end
|
77
24
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "faraday"
|
2
|
+
|
3
|
+
module Essence
|
4
|
+
class Client
|
5
|
+
attr_reader :client
|
6
|
+
|
7
|
+
def initialize(**attributes)
|
8
|
+
@client = ::Faraday.new(url: "https://essenceui.com/") do |f|
|
9
|
+
f.request :authorization, "Bearer", -> { ::Essence.configuration.licence_key }
|
10
|
+
f.request :json
|
11
|
+
f.response :json
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_component(slug: nil)
|
16
|
+
return if nil
|
17
|
+
client.get("api/v1/components/#{slug}").body
|
18
|
+
rescue Faraday::Error => error
|
19
|
+
puts error
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,11 +1,19 @@
|
|
1
1
|
module Essence
|
2
2
|
class Configuration
|
3
|
+
attr_accessor :licence_key
|
3
4
|
attr_accessor :phlex_components_path
|
4
|
-
attr_accessor :
|
5
|
+
attr_accessor :stimulus_controllers_path
|
6
|
+
|
7
|
+
attr_reader :phlex_components_dir
|
8
|
+
attr_reader :stimulus_controllers_dir
|
5
9
|
|
6
10
|
def initialize
|
11
|
+
@licence_key = nil
|
7
12
|
@phlex_components_path = "app/components"
|
8
|
-
@
|
13
|
+
@stimulus_controllers_path = "app/javascript/controllers/essence"
|
14
|
+
|
15
|
+
@phlex_components_dir = Pathname.new(File.expand_path(Dir.pwd)).join(@phlex_components_path)
|
16
|
+
@stimulus_controllers_dir = Pathname.new(File.expand_path(Dir.pwd)).join(@stimulus_controllers_path)
|
9
17
|
end
|
10
18
|
end
|
11
19
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Essence
|
2
|
+
DEFINITIONS = {
|
3
|
+
accordion: {
|
4
|
+
name: "Accordion",
|
5
|
+
class_name: "Essence::Accordion",
|
6
|
+
stimulus: false
|
7
|
+
},
|
8
|
+
alert: {
|
9
|
+
name: "Alert",
|
10
|
+
class_name: "Essence::Alert",
|
11
|
+
stimulus: false
|
12
|
+
},
|
13
|
+
avatar: {
|
14
|
+
name: "Avatar",
|
15
|
+
class_name: "Essence::Avatar",
|
16
|
+
stimulus: false
|
17
|
+
},
|
18
|
+
badge: {
|
19
|
+
name: "Badge",
|
20
|
+
class_name: "Essence::Badge",
|
21
|
+
stimulus: false
|
22
|
+
},
|
23
|
+
button: {
|
24
|
+
name: "Button",
|
25
|
+
class_name: "Essence::Button",
|
26
|
+
stimulus: false
|
27
|
+
},
|
28
|
+
checkbox: {
|
29
|
+
name: "Checkbox",
|
30
|
+
class_name: "Essence::Checkbox",
|
31
|
+
stimulus: false
|
32
|
+
},
|
33
|
+
heading: {
|
34
|
+
name: "Heading",
|
35
|
+
class_name: "Essence::Heading",
|
36
|
+
stimulus: false
|
37
|
+
},
|
38
|
+
label: {
|
39
|
+
name: "Label",
|
40
|
+
class_name: "Essence::Label",
|
41
|
+
stimulus: false
|
42
|
+
},
|
43
|
+
input: {
|
44
|
+
name: "Input",
|
45
|
+
class_name: "Essence::Input",
|
46
|
+
stimulus: false
|
47
|
+
},
|
48
|
+
link: {
|
49
|
+
name: "Link",
|
50
|
+
class_name: "Essence::Link",
|
51
|
+
stimulus: false
|
52
|
+
},
|
53
|
+
metric: {
|
54
|
+
name: "Metric",
|
55
|
+
class_name: "Essence::Metric",
|
56
|
+
stimulus: false
|
57
|
+
},
|
58
|
+
row: {
|
59
|
+
name: "Row",
|
60
|
+
class_name: "Essence::Row",
|
61
|
+
stimulus: false
|
62
|
+
},
|
63
|
+
separator: {
|
64
|
+
name: "Separator",
|
65
|
+
class_name: "Essence::Separator",
|
66
|
+
stimulus: false
|
67
|
+
},
|
68
|
+
skeleton: {
|
69
|
+
name: "Skeleton",
|
70
|
+
class_name: "Essence::Skeleton",
|
71
|
+
stimulus: false
|
72
|
+
},
|
73
|
+
switch: {
|
74
|
+
name: "Switch",
|
75
|
+
class_name: "Essence::Switch",
|
76
|
+
stimulus: true
|
77
|
+
},
|
78
|
+
tabs: {
|
79
|
+
name: "Tabs",
|
80
|
+
class_name: "Essence::Tabs",
|
81
|
+
stimulus: true
|
82
|
+
},
|
83
|
+
text: {
|
84
|
+
name: "Text",
|
85
|
+
class_name: "Essence::Text",
|
86
|
+
stimulus: false
|
87
|
+
}
|
88
|
+
}
|
89
|
+
end
|
data/lib/essence/version.rb
CHANGED
data/lib/essence.rb
CHANGED
@@ -1,23 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "tailwind_merge"
|
3
|
+
# require "tailwind_merge"
|
4
4
|
|
5
5
|
require_relative "essence/configuration"
|
6
|
+
require_relative "essence/definitions"
|
6
7
|
|
7
8
|
module Essence
|
8
|
-
# Autoloading
|
9
|
-
# Components
|
10
|
-
autoload :Accordion, "essence/components/accordion"
|
11
|
-
autoload :Avatar, "essence/components/avatar"
|
12
|
-
autoload :Badge, "essence/components/badge"
|
13
|
-
autoload :Button, "essence/components/button"
|
14
|
-
# autoload :Essence, "essence/components/essence" # Base component
|
15
|
-
autoload :Link, "essence/components/link"
|
16
|
-
autoload :Row, "essence/components/row"
|
17
|
-
autoload :Skeleton, "essence/components/skeleton"
|
18
|
-
|
19
|
-
# CLI
|
20
9
|
autoload :CLI, "essence/cli"
|
10
|
+
autoload :Client, "essence/client"
|
21
11
|
|
22
12
|
class << self
|
23
13
|
def root_path
|
@@ -33,6 +23,10 @@ module Essence
|
|
33
23
|
yield configuration
|
34
24
|
end
|
35
25
|
|
26
|
+
def definitions
|
27
|
+
@definitions ||= Essence::DEFINITIONS
|
28
|
+
end
|
29
|
+
|
36
30
|
# COMPONENTS
|
37
31
|
def components
|
38
32
|
@components ||= {
|
@@ -41,6 +35,11 @@ module Essence
|
|
41
35
|
class_name: "Essence::Accordion",
|
42
36
|
stimulus: false
|
43
37
|
},
|
38
|
+
alert: {
|
39
|
+
name: "Alert",
|
40
|
+
class_name: "Essence::Alert",
|
41
|
+
stimulus: false
|
42
|
+
},
|
44
43
|
avatar: {
|
45
44
|
name: "Avatar",
|
46
45
|
class_name: "Essence::Avatar",
|
@@ -56,21 +55,51 @@ module Essence
|
|
56
55
|
class_name: "Essence::Button",
|
57
56
|
stimulus: false
|
58
57
|
},
|
58
|
+
checkbox: {
|
59
|
+
name: "Checkbox",
|
60
|
+
class_name: "Essence::Checkbox",
|
61
|
+
stimulus: false
|
62
|
+
},
|
63
|
+
label: {
|
64
|
+
name: "Label",
|
65
|
+
class_name: "Essence::Label",
|
66
|
+
stimulus: false
|
67
|
+
},
|
68
|
+
input: {
|
69
|
+
name: "Input",
|
70
|
+
class_name: "Essence::Input",
|
71
|
+
stimulus: false
|
72
|
+
},
|
59
73
|
link: {
|
60
74
|
name: "Link",
|
61
75
|
class_name: "Essence::Link",
|
62
76
|
stimulus: false
|
63
77
|
},
|
78
|
+
metric: {
|
79
|
+
name: "Metric",
|
80
|
+
class_name: "Essence::Metric",
|
81
|
+
stimulus: false
|
82
|
+
},
|
64
83
|
row: {
|
65
84
|
name: "Row",
|
66
85
|
class_name: "Essence::Row",
|
67
86
|
stimulus: false
|
68
87
|
},
|
88
|
+
separator: {
|
89
|
+
name: "Separator",
|
90
|
+
class_name: "Essence::Separator",
|
91
|
+
stimulus: false
|
92
|
+
},
|
69
93
|
skeleton: {
|
70
94
|
name: "Skeleton",
|
71
95
|
class_name: "Essence::Skeleton",
|
72
96
|
stimulus: false
|
73
97
|
},
|
98
|
+
switch: {
|
99
|
+
name: "Switch",
|
100
|
+
class_name: "Essence::Switch",
|
101
|
+
stimulus: true
|
102
|
+
},
|
74
103
|
tabs: {
|
75
104
|
name: "Tabs",
|
76
105
|
class_name: "Essence::Tabs",
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: essence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elvinas Predkelis
|
8
|
-
- Primevise
|
9
|
-
autorequire:
|
10
8
|
bindir: exe
|
11
9
|
cert_chain: []
|
12
|
-
date: 2025-
|
10
|
+
date: 2025-05-11 00:00:00.000000000 Z
|
13
11
|
dependencies:
|
14
12
|
- !ruby/object:Gem::Dependency
|
15
13
|
name: dry-cli
|
@@ -32,61 +30,37 @@ dependencies:
|
|
32
30
|
- !ruby/object:Gem::Version
|
33
31
|
version: '2'
|
34
32
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
33
|
+
name: faraday
|
36
34
|
requirement: !ruby/object:Gem::Requirement
|
37
35
|
requirements:
|
38
|
-
- - "
|
36
|
+
- - "~>"
|
39
37
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
38
|
+
version: '2.13'
|
41
39
|
type: :runtime
|
42
40
|
prerelease: false
|
43
41
|
version_requirements: !ruby/object:Gem::Requirement
|
44
42
|
requirements:
|
45
|
-
- - "
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 2.0.0.rc1
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: tailwind_merge
|
50
|
-
requirement: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.13.3
|
55
|
-
type: :runtime
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
43
|
+
- - "~>"
|
60
44
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
45
|
+
version: '2.13'
|
62
46
|
description: Component library for Ruby applications using Phlex
|
63
47
|
email:
|
64
|
-
-
|
48
|
+
- elvinas@primevise.com
|
65
49
|
executables:
|
66
50
|
- essence
|
67
51
|
extensions: []
|
68
52
|
extra_rdoc_files: []
|
69
53
|
files:
|
70
54
|
- README.md
|
71
|
-
- essence/stimulus/tabs_controller.js
|
72
55
|
- exe/essence
|
73
56
|
- lib/essence.rb
|
74
57
|
- lib/essence/cli.rb
|
75
58
|
- lib/essence/cli/add.rb
|
76
59
|
- lib/essence/cli/install.rb
|
77
60
|
- lib/essence/cli/version.rb
|
78
|
-
- lib/essence/
|
79
|
-
- lib/essence/components/avatar.rb
|
80
|
-
- lib/essence/components/badge.rb
|
81
|
-
- lib/essence/components/button.rb
|
82
|
-
- lib/essence/components/dialog.rb
|
83
|
-
- lib/essence/components/dropdown.rb
|
84
|
-
- lib/essence/components/essence.rb
|
85
|
-
- lib/essence/components/link.rb
|
86
|
-
- lib/essence/components/row.rb
|
87
|
-
- lib/essence/components/skeleton.rb
|
88
|
-
- lib/essence/components/tabs.rb
|
61
|
+
- lib/essence/client.rb
|
89
62
|
- lib/essence/configuration.rb
|
63
|
+
- lib/essence/definitions.rb
|
90
64
|
- lib/essence/version.rb
|
91
65
|
homepage: https://rubygems.org/gems/essence
|
92
66
|
licenses:
|
@@ -94,7 +68,6 @@ licenses:
|
|
94
68
|
metadata:
|
95
69
|
homepage_uri: https://rubygems.org/gems/essence
|
96
70
|
source_code_uri: https://github.com/primevise/essence
|
97
|
-
post_install_message:
|
98
71
|
rdoc_options: []
|
99
72
|
require_paths:
|
100
73
|
- lib
|
@@ -109,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
82
|
- !ruby/object:Gem::Version
|
110
83
|
version: '0'
|
111
84
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
113
|
-
signing_key:
|
85
|
+
rubygems_version: 3.6.2
|
114
86
|
specification_version: 4
|
115
87
|
summary: Component library for Ruby applications using Phlex
|
116
88
|
test_files: []
|
@@ -1,40 +0,0 @@
|
|
1
|
-
import { Controller } from "@hotwired/stimulus";
|
2
|
-
|
3
|
-
export default class extends Controller {
|
4
|
-
static targets = ["tab", "panel"];
|
5
|
-
static values = { active: String };
|
6
|
-
|
7
|
-
setActiveTab(event) {
|
8
|
-
this.activeValue = event.params.panelId;
|
9
|
-
}
|
10
|
-
|
11
|
-
activeValueChanged() {
|
12
|
-
this.tabTargets.forEach((tab) => {
|
13
|
-
tab.ariaSelected = tab.id === this.activeValue;
|
14
|
-
});
|
15
|
-
|
16
|
-
this.panelTargets.forEach((panel) => {
|
17
|
-
panel.ariaHidden = panel.id !== this.activeValue;
|
18
|
-
});
|
19
|
-
}
|
20
|
-
|
21
|
-
next(event) {
|
22
|
-
this.navigate(event, "next");
|
23
|
-
}
|
24
|
-
|
25
|
-
previous(event) {
|
26
|
-
this.navigate(event, "previous");
|
27
|
-
}
|
28
|
-
|
29
|
-
navigate(event, direction) {
|
30
|
-
const tab =
|
31
|
-
direction === "next"
|
32
|
-
? event.target.nextElementSibling
|
33
|
-
: event.target.previousElementSibling;
|
34
|
-
|
35
|
-
if (!tab) return;
|
36
|
-
|
37
|
-
tab.click();
|
38
|
-
tab.focus();
|
39
|
-
}
|
40
|
-
}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Essence::Accordion < Essence::Essence
|
4
|
-
BASE = "group py-4"
|
5
|
-
TRIGGER_BASE = "cursor-pointer list-none flex items-center justify-between text-base font-medium"
|
6
|
-
CONTENT_BASE = "py-2 transform transition-all duration-500 not-open:-mt-4 opacity-0 group-open:opacity-100 group-open:mt-0 text-sm"
|
7
|
-
CHEVRON_BASE = "transform transition-all duration-300 rotate-90 group-open:-rotate-90 text-lg text-gray-700"
|
8
|
-
|
9
|
-
attr_reader :attributes
|
10
|
-
|
11
|
-
def initialize(**attributes)
|
12
|
-
super(**attributes)
|
13
|
-
@attributes[:class] = merge_classes([ BASE, @attributes[:class]])
|
14
|
-
end
|
15
|
-
|
16
|
-
def view_template(&)
|
17
|
-
details(class: "w-full group py-4", &) if block_given?
|
18
|
-
end
|
19
|
-
|
20
|
-
def trigger(**tattributes, &)
|
21
|
-
summary(class: merge_classes(TRIGGER_BASE, tattributes[:class])) do
|
22
|
-
p(class: "inline", &)
|
23
|
-
span(class: CHEVRON_BASE) { "›" }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def content(**cattributes, &)
|
28
|
-
p(class: merge_classes(CONTENT_BASE, cattributes[:class]), &)
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def merge_classes(*classes)
|
34
|
-
TAILWIND_MERGER.merge([ *classes ].compact)
|
35
|
-
end
|
36
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Essence::Avatar < Essence::Essence
|
4
|
-
BASE = "border border-transparent rounded-full bg-gray-100 aspect-square inline-flex items-center justify-center font-medium text-gray-700 overflow-hidden"
|
5
|
-
|
6
|
-
SIZES = {
|
7
|
-
sm: "size-6 text-[0.5rem]",
|
8
|
-
md: "size-8 text-xs",
|
9
|
-
lg: "size-12 text-sm"
|
10
|
-
}
|
11
|
-
|
12
|
-
attr_reader :attributes
|
13
|
-
attr_reader :size
|
14
|
-
|
15
|
-
def initialize(size: :md, **attributes)
|
16
|
-
super(**attributes)
|
17
|
-
@size = size
|
18
|
-
@attributes[:class] = merge_classes([ BASE, SIZES[size], @attributes[:class]])
|
19
|
-
end
|
20
|
-
|
21
|
-
def view_template(&)
|
22
|
-
div(**attributes) do
|
23
|
-
img(src: attributes[:src], alt: attributes[:alt]) if attributes[:src]
|
24
|
-
yield if block_given?
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def fallback(**attrs, &)
|
29
|
-
div(**attrs, &)
|
30
|
-
end
|
31
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Essence::Badge < Essence::Essence
|
4
|
-
BASE = "inline-flex items-center justify-center w-fit rounded-full border border-transparent font-medium transition duration-150 hover:opacity-90"
|
5
|
-
SIZES = {
|
6
|
-
none: "",
|
7
|
-
sm: "text-[0.65rem] px-2 py-0.5 gap-1 min-w-8",
|
8
|
-
md: "text-xs px-2.5 py-1 gap-2 min-w-12",
|
9
|
-
lg: "text-sm px-4 py-1 gap-2 min-w-16"
|
10
|
-
}
|
11
|
-
KINDS = {
|
12
|
-
primary: "text-gray-900 border-gray-200",
|
13
|
-
success: "text-white bg-emerald-500",
|
14
|
-
critical: "text-white bg-rose-500",
|
15
|
-
warning: "text-white bg-amber-500",
|
16
|
-
info: "text-white bg-blue-500",
|
17
|
-
dark: "text-white bg-gray-900",
|
18
|
-
white: "text-gray-900 bg-white"
|
19
|
-
}
|
20
|
-
|
21
|
-
attr_reader :size
|
22
|
-
attr_reader :kind
|
23
|
-
attr_reader :attributes
|
24
|
-
|
25
|
-
def initialize(size: :md, kind: :primary, **attributes)
|
26
|
-
@size = size
|
27
|
-
@kind = kind
|
28
|
-
super(**attributes)
|
29
|
-
@attributes[:class] = merge_classes([ BASE, SIZES[size], KINDS[kind], @attributes[:class]])
|
30
|
-
end
|
31
|
-
|
32
|
-
def view_template(&)
|
33
|
-
div(**attributes, &)
|
34
|
-
end
|
35
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Essence::Button < Essence::Essence
|
4
|
-
BASE = "inline-flex items-center justify-center w-fit rounded-xs border border-transparent font-medium transition duration-150 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed hover:opacity-90"
|
5
|
-
SIZES = {
|
6
|
-
none: "",
|
7
|
-
xs: "text-[0.6rem] px-2 py-1.5 gap-1",
|
8
|
-
sm: "text-xs px-3 py-2 gap-1.5",
|
9
|
-
md: "text-sm px-4 py-2 gap-2",
|
10
|
-
lg: "text-base px-6 py-2.5 gap-2.5",
|
11
|
-
xl: "text-base px-8 py-3 gap-3"
|
12
|
-
}
|
13
|
-
KINDS = {
|
14
|
-
primary: "text-white bg-indigo-500 hover:bg-indigo-500",
|
15
|
-
secondary: "text-gray-700 bg-gray-100 hover:bg-gray-200",
|
16
|
-
critical: "text-white bg-rose-500 hover:bg-rose-400",
|
17
|
-
warning: "text-white bg-amber-500 hover:bg-amber-400",
|
18
|
-
success: "text-white bg-emerald-500 hover:bg-emerald-400",
|
19
|
-
info: "text-white bg-blue-500 hover:bg-blue-400",
|
20
|
-
dark: "text-white bg-gray-900 hover:bg-gray-800",
|
21
|
-
white: "text-gray-900 bg-white hover:bg-gray-200",
|
22
|
-
ghost: "text-gray-900 hover:bg-gray-200 hover:text-gray-800"
|
23
|
-
}
|
24
|
-
|
25
|
-
attr_reader :size
|
26
|
-
attr_reader :kind
|
27
|
-
attr_reader :attributes
|
28
|
-
|
29
|
-
def initialize(size: :md, kind: :primary, **attributes)
|
30
|
-
@size = size
|
31
|
-
@kind = kind
|
32
|
-
super(**attributes)
|
33
|
-
@attributes[:class] = merge_classes([ BASE, SIZES[size], KINDS[kind], @attributes[:class]])
|
34
|
-
end
|
35
|
-
|
36
|
-
def view_template(&)
|
37
|
-
element_tag(**attributes, &)
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def element_tag(...)
|
43
|
-
attributes[:href] ? a(...) : button(...)
|
44
|
-
end
|
45
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Essence::Dialog < Essence::Essence
|
4
|
-
BASE = ""
|
5
|
-
|
6
|
-
attr_reader :attributes
|
7
|
-
|
8
|
-
def initialize(**attributes)
|
9
|
-
super(**attributes)
|
10
|
-
@attributes[:class] = merge_classes([ BASE, @attributes[:class]])
|
11
|
-
end
|
12
|
-
|
13
|
-
def view_template(&)
|
14
|
-
dialog(**attributes) do
|
15
|
-
yield if block_given?
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def footer(&)
|
20
|
-
end
|
21
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Essence::Dropdown < Essence::Essence
|
4
|
-
BASE = ""
|
5
|
-
|
6
|
-
attr_reader :attributes
|
7
|
-
|
8
|
-
def initialize(**attributes)
|
9
|
-
super(**attributes)
|
10
|
-
@attributes[:class] = merge_classes([ BASE, @attributes[:class]])
|
11
|
-
end
|
12
|
-
|
13
|
-
def view_template(&)
|
14
|
-
div(**attributes) do
|
15
|
-
yield if block_given?
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class Essence::Essence < Phlex::HTML
|
2
|
-
extend Phlex::Kit
|
3
|
-
|
4
|
-
TAILWIND_MERGER = ::TailwindMerge::Merger.new.freeze unless defined?(TAILWIND_MERGER)
|
5
|
-
|
6
|
-
attr_reader :attributes
|
7
|
-
|
8
|
-
def initialize(**attributes)
|
9
|
-
@attributes = default_attributes.deep_merge(attributes)
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def default_attributes = {}
|
15
|
-
def merge_classes(*classes) = TAILWIND_MERGER.merge([ *classes ].compact)
|
16
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Essence::Link < Essence::Essence
|
4
|
-
BASE = "inline-flex w-fit items-center gap-1 font-medium text-gray-900 border-b-2 hover:border-gray-900 transition-colors"
|
5
|
-
KINDS = {
|
6
|
-
regular: "border-transparent",
|
7
|
-
underline: "border-gray-200"
|
8
|
-
}
|
9
|
-
|
10
|
-
attr_reader :attributes
|
11
|
-
|
12
|
-
def initialize(kind: :regular, **attributes)
|
13
|
-
super(**attributes)
|
14
|
-
@attributes[:class] = merge_classes([ BASE, @attributes[:class]])
|
15
|
-
end
|
16
|
-
|
17
|
-
def view_template(&)
|
18
|
-
a(**attributes, &)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Essence::Row < Essence::Essence
|
4
|
-
BASE = "flex gap-4"
|
5
|
-
KINDS = {
|
6
|
-
default: "flex-col md:flex-row md:items-center md:justify-between",
|
7
|
-
center: "flex-col md:flex-row md:items-center md:justify-center",
|
8
|
-
start: "flex-col md:flex-row md:items-center md:justify-start",
|
9
|
-
end: "flex-col md:flex-row md:items-center md:justify-end",
|
10
|
-
}
|
11
|
-
|
12
|
-
attr_reader :kind
|
13
|
-
attr_reader :attributes
|
14
|
-
|
15
|
-
def initialize(kind: :default, **attributes)
|
16
|
-
@kind = kind
|
17
|
-
super(**attributes)
|
18
|
-
@attributes[:class] = merge_classes([ BASE, KINDS[kind], @attributes[:class]])
|
19
|
-
end
|
20
|
-
|
21
|
-
def view_template(&)
|
22
|
-
div(**attributes, &)
|
23
|
-
end
|
24
|
-
|
25
|
-
def item(**attrs, &)
|
26
|
-
div(class: TAILWIND_MERGER.merge([ "flex items-center gap-2 flex-wrap", attrs[:class] ]), **attrs, &)
|
27
|
-
end
|
28
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# A skeleton component is used to show a loading state.
|
4
|
-
#
|
5
|
-
# ==== Examples
|
6
|
-
#
|
7
|
-
# render Skeleton.new(class: "w-32 h-6")
|
8
|
-
#
|
9
|
-
# ==== Documentation
|
10
|
-
#
|
11
|
-
# https://essence.primevise.com/components/skeleton
|
12
|
-
#
|
13
|
-
class Essence::Skeleton < Essence::Essence
|
14
|
-
BASE = "animate-pulse bg-gray-200/55 rounded-xs"
|
15
|
-
|
16
|
-
def initialize(**attributes)
|
17
|
-
super(**attributes)
|
18
|
-
@attributes[:class] = merge_classes([ BASE, @attributes[:class]])
|
19
|
-
end
|
20
|
-
|
21
|
-
def view_template(&)
|
22
|
-
div(**@attributes, &)
|
23
|
-
end
|
24
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Essence::Tabs < Essence::Essence
|
4
|
-
BASE = "rounded-lg overflow-hidden"
|
5
|
-
TAB_BASE = "inline-flex items-center justify-center w-fit rounded-xs border border-transparent font-medium transition duration-150 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed hover:opacity-90 text-xs px-3 py-2 gap-1.5 text-gray-900 bg-transparent hover:bg-gray-200 hover:text-gray-800"
|
6
|
-
TAB_LIST_BASE = "flex items-center gap-2 py-2 border-b"
|
7
|
-
PANEL_BASE = "aria-hidden:hidden p-4"
|
8
|
-
|
9
|
-
attr_reader :attributes
|
10
|
-
|
11
|
-
def initialize(**attributes)
|
12
|
-
super(**attributes)
|
13
|
-
@attributes[:class] = merge_classes([ BASE, @attributes[:class] ])
|
14
|
-
end
|
15
|
-
|
16
|
-
def view_template(&)
|
17
|
-
div(**attributes, &)
|
18
|
-
end
|
19
|
-
|
20
|
-
def menu(**mattributes, &)
|
21
|
-
mattributes[:class] = merge_classes([ TAB_LIST_BASE, mattributes[:class] ])
|
22
|
-
|
23
|
-
div(**mattributes, &)
|
24
|
-
end
|
25
|
-
|
26
|
-
def tab(key: :general, **mattributes, &)
|
27
|
-
mattributes[:id] = "tab-#{key}"
|
28
|
-
mattributes[:class] = merge_classes([ TAB_BASE, mattributes[:class] ])
|
29
|
-
mattributes[:data] = {
|
30
|
-
essence__tabs_target: "tab",
|
31
|
-
essence__tabs_panel_id_param: "panel-#{key}",
|
32
|
-
action: "essence--tabs#setActiveTab keydown.left->essence--tabs#previous keydown.right->essence--tabs#next"
|
33
|
-
}
|
34
|
-
|
35
|
-
button(**mattributes, &)
|
36
|
-
end
|
37
|
-
|
38
|
-
def panel(key: :general, **mattributes, &)
|
39
|
-
mattributes[:id] = "panel-#{key}"
|
40
|
-
mattributes[:class] = merge_classes([ PANEL_BASE, mattributes[:class] ])
|
41
|
-
mattributes[:data] = {
|
42
|
-
essence__tabs_target: "panel"
|
43
|
-
}
|
44
|
-
|
45
|
-
div(**mattributes, &)
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def default_attributes
|
51
|
-
{
|
52
|
-
data: {
|
53
|
-
controller: "essence--tabs",
|
54
|
-
essence__tabs_active_value: "panel-general"
|
55
|
-
}
|
56
|
-
}
|
57
|
-
end
|
58
|
-
end
|