pulse_view_components 0.3.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 +7 -0
- data/CHANGELOG.md +88 -0
- data/LICENSE.txt +22 -0
- data/README.md +78 -0
- data/app/assets/builds/js/pulse_view_components.js +9543 -0
- data/app/assets/builds/js/pulse_view_components.js.map +7 -0
- data/app/assets/builds/pulse_view_components.css +1 -0
- data/app/assets/config/manifest.js +2 -0
- data/app/assets/images/pulse_view_components/icons/alert.svg +3 -0
- data/app/assets/images/pulse_view_components/icons/archive.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/arrow-both.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/arrow-down.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/arrow-left.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/arrow-right.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/arrow-switch.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/arrow-up.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/beaker.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/bell-slash.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/bell.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/bookmark-slash.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/bookmark.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/calendar.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/check-circle.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/check.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/chevron-down.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/circle.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/clock.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/close.svg +9 -0
- data/app/assets/images/pulse_view_components/icons/cloud.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/comment-discussion.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/comment.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/copy.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/database.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/dot.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/dots-outline.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/download.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/duplicate.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/eye.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/file-added.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/file-directory.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/file-media.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/file.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/filter.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/flame.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/gear.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/gift.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/globe.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/goal.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/graph.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/heart-fill.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/heart.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/history.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/home.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/hourglass.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/image.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/inbox.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/info.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/issue.svg +3 -0
- data/app/assets/images/pulse_view_components/icons/key.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/law.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/link-external.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/link.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/location.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/log.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/mail.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/mark-github.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/mark-jira.svg +3 -0
- data/app/assets/images/pulse_view_components/icons/megaphone.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/no-entry.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/note.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/organization.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/package.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/paintbrush.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/paperclip.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/paste.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/pencil.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/people.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/person-add.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/person.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/pin-slash.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/pin.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/play.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/plus-circle.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/plus.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/project.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/pulse.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/question.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/redo.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/reply.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/report.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/rss.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/ruby.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/search.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/share.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/shield.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/sliders.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/smiley.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/sort.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/sort_asc.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/sort_desc.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/stack.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/star-fill.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/star.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/stopwatch.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/sun.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/sync.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/table.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/tag.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/tasklist.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/telescope.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/three-bars.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/thumbsdown.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/thumbsup.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/tools.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/trash.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/trophy.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/undo.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/unlink.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/upload.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/x-circle.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/x.svg +1 -0
- data/app/assets/images/pulse_view_components/icons/zap.svg +1 -0
- data/app/assets/javascripts/pulse_view_components.js +0 -0
- data/app/assets/stylesheets/pulse_view_components/application.tailwind.css +10 -0
- data/app/components/pulse/action_list/divider.rb +35 -0
- data/app/components/pulse/action_list/form_wrapper.html.slim +9 -0
- data/app/components/pulse/action_list/form_wrapper.rb +63 -0
- data/app/components/pulse/action_list/heading.rb +52 -0
- data/app/components/pulse/action_list/item.html.slim +43 -0
- data/app/components/pulse/action_list/item.rb +319 -0
- data/app/components/pulse/action_list.css +568 -0
- data/app/components/pulse/action_list.rb +261 -0
- data/app/components/pulse/badge.rb +59 -0
- data/app/components/pulse/base_component.rb +36 -0
- data/app/components/pulse/blank_slate.html.slim +10 -0
- data/app/components/pulse/blank_slate.rb +19 -0
- data/app/components/pulse/blank_slate.yml +2 -0
- data/app/components/pulse/border_box/header.html.slim +4 -0
- data/app/components/pulse/border_box/header.rb +48 -0
- data/app/components/pulse/border_box.html.slim +10 -0
- data/app/components/pulse/border_box.rb +124 -0
- data/app/components/pulse/box.rb +17 -0
- data/app/components/pulse/breadcrumb_item.rb +40 -0
- data/app/components/pulse/breadcrumbs.html.slim +9 -0
- data/app/components/pulse/breadcrumbs.rb +17 -0
- data/app/components/pulse/button.rb +148 -0
- data/app/components/pulse/component.rb +99 -0
- data/app/components/pulse/conditional_wrapper.rb +21 -0
- data/app/components/pulse/content.rb +11 -0
- data/app/components/pulse/counter.css +10 -0
- data/app/components/pulse/counter.rb +107 -0
- data/app/components/pulse/flash.html.slim +9 -0
- data/app/components/pulse/flash.rb +52 -0
- data/app/components/pulse/forms/error_explanation.html.slim +8 -0
- data/app/components/pulse/forms/error_explanation.rb +36 -0
- data/app/components/pulse/icon.rb +30 -0
- data/app/components/pulse/label.html.slim +5 -0
- data/app/components/pulse/label.rb +42 -0
- data/app/components/pulse/layout.css +239 -0
- data/app/components/pulse/layout.html.slim +7 -0
- data/app/components/pulse/layout.rb +141 -0
- data/app/components/pulse/link.html.slim +7 -0
- data/app/components/pulse/link.rb +52 -0
- data/app/components/pulse/modal.html.slim +51 -0
- data/app/components/pulse/modal.rb +64 -0
- data/app/components/pulse/modal_controller.js +77 -0
- data/app/components/pulse/nav_link.html.slim +16 -0
- data/app/components/pulse/nav_link.rb +25 -0
- data/app/components/pulse/nav_list/divider.rb +13 -0
- data/app/components/pulse/nav_list/group.html.slim +6 -0
- data/app/components/pulse/nav_list/group.rb +110 -0
- data/app/components/pulse/nav_list/heading.rb +36 -0
- data/app/components/pulse/nav_list/item.rb +171 -0
- data/app/components/pulse/nav_list.html.slim +11 -0
- data/app/components/pulse/nav_list.rb +225 -0
- data/app/components/pulse/popover.html.slim +5 -0
- data/app/components/pulse/popover.rb +88 -0
- data/app/components/pulse/progress_bar.html.slim +5 -0
- data/app/components/pulse/progress_bar.rb +23 -0
- data/app/components/pulse/progress_bar.yml +2 -0
- data/app/components/pulse/table/cell.html.slim +10 -0
- data/app/components/pulse/table/cell.rb +90 -0
- data/app/components/pulse/table/cell.yml +5 -0
- data/app/components/pulse/table/column.rb +22 -0
- data/app/components/pulse/table.html.slim +50 -0
- data/app/components/pulse/table.rb +111 -0
- data/app/components/pulse/table.yml +2 -0
- data/app/components/pulse/text.rb +72 -0
- data/app/components/pulse/toast.html.slim +14 -0
- data/app/components/pulse/toast.rb +85 -0
- data/app/components/pulse/toast_controller.js +32 -0
- data/app/javascript/pulse_view_components/application.js +24 -0
- data/app/javascript/pulse_view_components.js +4 -0
- data/app/lib/pulse/attributes_helper.rb +107 -0
- data/app/lib/pulse/fetch_or_fallback_helper.rb +53 -0
- data/app/lib/pulse/svg_helper.rb +28 -0
- data/lib/pulse/view_components/engine.rb +74 -0
- data/lib/pulse/view_components/version.rb +17 -0
- data/lib/pulse/view_components.rb +14 -0
- data/lib/pulse_view_components.rb +3 -0
- data/lib/tasks/pulse_view_components_tasks.rake +8 -0
- data/previews/pulse/badge_preview.rb +51 -0
- data/previews/pulse/blank_slate_preview.rb +14 -0
- data/previews/pulse/border_box_preview.rb +48 -0
- data/previews/pulse/breadcrumbs_preview.rb +13 -0
- data/previews/pulse/button_preview.rb +137 -0
- data/previews/pulse/counter_preview.rb +14 -0
- data/previews/pulse/flash_preview.rb +85 -0
- data/previews/pulse/icon_preview.rb +12 -0
- data/previews/pulse/label_preview.rb +10 -0
- data/previews/pulse/layout_preview.rb +34 -0
- data/previews/pulse/link_preview.rb +55 -0
- data/previews/pulse/modal_preview.rb +48 -0
- data/previews/pulse/nav_link_preview.rb +48 -0
- data/previews/pulse/nav_list_preview.rb +138 -0
- data/previews/pulse/popover_preview.rb +77 -0
- data/previews/pulse/progress_bar_preview.rb +23 -0
- data/previews/pulse/table_preview.rb +168 -0
- data/previews/pulse/text_preview.rb +102 -0
- data/previews/pulse/toast_preview.rb +67 -0
- metadata +344 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# FetchOrFallbackHelper
|
|
5
|
+
# A little helper to enable graceful fallbacks
|
|
6
|
+
# See https://github.com/primer/view_components/blob/main/app/lib/primer/fetch_or_fallback_helper.rb
|
|
7
|
+
# and https://github.com/baoagency/polaris_view_components/blob/main/app/helpers/polaris/fetch_or_fallback_helper.rb
|
|
8
|
+
#
|
|
9
|
+
# Use this helper to quietly ensure a value is
|
|
10
|
+
# one that you expect:
|
|
11
|
+
#
|
|
12
|
+
# allowed_values - allowed options for *value*
|
|
13
|
+
# given_value - input being coerced
|
|
14
|
+
# fallback - returned if *given_value* is not included in *allowed_values*
|
|
15
|
+
#
|
|
16
|
+
# fetch_or_fallback([1,2,3], 5, 2) => 2
|
|
17
|
+
# fetch_or_fallback([1,2,3], 1, 2) => 1
|
|
18
|
+
# fetch_or_fallback([1,2,3], nil, 2) => 2
|
|
19
|
+
module FetchOrFallbackHelper
|
|
20
|
+
mattr_accessor :fallback_raises, default: true
|
|
21
|
+
|
|
22
|
+
class InvalidValueError < StandardError
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def fetch_or_fallback(allowed_values, given_value, fallback = nil)
|
|
26
|
+
if allowed_values.include?(given_value)
|
|
27
|
+
given_value
|
|
28
|
+
else
|
|
29
|
+
if fallback_raises && ENV['RAILS_ENV'] != 'production'
|
|
30
|
+
raise InvalidValueError, <<~MSG
|
|
31
|
+
fetch_or_fallback was called with an invalid value.
|
|
32
|
+
|
|
33
|
+
Expected one of: #{allowed_values.inspect}
|
|
34
|
+
Got: #{given_value.inspect}
|
|
35
|
+
|
|
36
|
+
This will not raise in production, but will instead fallback to: #{fallback.inspect}
|
|
37
|
+
MSG
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
fallback
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# rubocop:disable-next Style/OptionalBooleanParameter
|
|
45
|
+
def fetch_or_fallback_boolean(given_value, fallback = false)
|
|
46
|
+
if [true, false].include?(given_value)
|
|
47
|
+
given_value
|
|
48
|
+
else
|
|
49
|
+
fallback
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# Helpers for inline svg
|
|
5
|
+
module SvgHelper
|
|
6
|
+
# Render an embedded svg document
|
|
7
|
+
# @param name [String] any filename present in the asset pipeline search paths
|
|
8
|
+
# @param options [Hash] any additional options which `inline_svg_tag` accepts
|
|
9
|
+
# @note Do not include the `.svg` suffix in the filename
|
|
10
|
+
# @see https://github.com/jamesmartin/inline_svg#options Options documentation
|
|
11
|
+
def render_svg(name, **options)
|
|
12
|
+
if options[:title].blank?
|
|
13
|
+
options[:aria_hidden] ||= true
|
|
14
|
+
options[:aria] = nil
|
|
15
|
+
else
|
|
16
|
+
options[:aria] ||= true
|
|
17
|
+
end
|
|
18
|
+
options[:nocomment] ||= true
|
|
19
|
+
options[:class] = class_names(
|
|
20
|
+
options[:class],
|
|
21
|
+
options[:classes]
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
filename = "#{name}.svg"
|
|
25
|
+
inline_svg_tag(filename, **options)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails/engine'
|
|
4
|
+
require 'view_component'
|
|
5
|
+
# require 'view_component/version'
|
|
6
|
+
|
|
7
|
+
module Pulse
|
|
8
|
+
module ViewComponents
|
|
9
|
+
# :nodoc:
|
|
10
|
+
class Engine < ::Rails::Engine
|
|
11
|
+
isolate_namespace Pulse::ViewComponents
|
|
12
|
+
|
|
13
|
+
%W(
|
|
14
|
+
#{root}/app/components
|
|
15
|
+
#{root}/lib
|
|
16
|
+
).each { |path| config.autoload_paths << path }
|
|
17
|
+
|
|
18
|
+
# config.eager_load_paths = %W[
|
|
19
|
+
# #{root}/app/components
|
|
20
|
+
# #{root}/app/forms
|
|
21
|
+
# #{root}/app/helpers
|
|
22
|
+
# #{root}/app/lib
|
|
23
|
+
# ]
|
|
24
|
+
config.eager_load_paths = %W(
|
|
25
|
+
#{root}/app/components
|
|
26
|
+
#{root}/app/lib
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# config.pulse_view_components = ActiveSupport::OrderedOptions.new
|
|
30
|
+
|
|
31
|
+
# config.pulse_view_components.raise_on_invalid_options = false
|
|
32
|
+
|
|
33
|
+
# initializer 'pulse_view_components.assets' do |app|
|
|
34
|
+
# if app.config.respond_to?(:assets)
|
|
35
|
+
# app.config.assets.precompile += %w(pulse_view_components)
|
|
36
|
+
# end
|
|
37
|
+
# end
|
|
38
|
+
|
|
39
|
+
# initializer 'pulse.eager_load_actions' do
|
|
40
|
+
# ActiveSupport.on_load(:after_initialize) do
|
|
41
|
+
# if Rails.application.config.eager_load
|
|
42
|
+
# # Pulse::Forms::Base.compile!
|
|
43
|
+
# # Pulse::Forms::Base.descendants.each(&:compile!)
|
|
44
|
+
# # Pulse::Forms::BaseComponent.descendants.each(&:compile!)
|
|
45
|
+
# # Pulse::Octicon::Cache.preload!
|
|
46
|
+
# end
|
|
47
|
+
# end
|
|
48
|
+
# end
|
|
49
|
+
|
|
50
|
+
# Polaris
|
|
51
|
+
|
|
52
|
+
# initializer "polaris_view_components.assets" do |app|
|
|
53
|
+
# if app.config.respond_to?(:assets)
|
|
54
|
+
# app.config.assets.precompile += %w[
|
|
55
|
+
# polaris_view_components.js polaris_view_components.css
|
|
56
|
+
# ]
|
|
57
|
+
# end
|
|
58
|
+
# end
|
|
59
|
+
|
|
60
|
+
# initializer "polaris_view_components.importmap", before: "importmap" do |app|
|
|
61
|
+
# if app.config.respond_to?(:importmap) && app.config.importmap.has_key?(:cache_sweepers)
|
|
62
|
+
# app.config.importmap.cache_sweepers << Engine.root.join("app/assets/javascripts")
|
|
63
|
+
# end
|
|
64
|
+
# end
|
|
65
|
+
|
|
66
|
+
# initializer "polaris_view_components.helpers" do
|
|
67
|
+
# ActiveSupport.on_load(:action_controller_base) do
|
|
68
|
+
# helper Polaris::ViewHelper
|
|
69
|
+
# helper Polaris::UrlHelper
|
|
70
|
+
# end
|
|
71
|
+
# end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# simplecov:disable
|
|
4
|
+
module Pulse
|
|
5
|
+
module ViewComponents
|
|
6
|
+
module VERSION
|
|
7
|
+
MAJOR = 0
|
|
8
|
+
MINOR = 3
|
|
9
|
+
PATCH = 0
|
|
10
|
+
|
|
11
|
+
STRING = [MAJOR, MINOR, PATCH].join('.')
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# rubocop:disable-next Rails/Output
|
|
17
|
+
puts Pulse::ViewComponents::VERSION::STRING if __FILE__ == $PROGRAM_NAME
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'pulse/view_components/version'
|
|
4
|
+
require 'pulse/view_components/engine'
|
|
5
|
+
|
|
6
|
+
module Pulse
|
|
7
|
+
# :nodoc:
|
|
8
|
+
module ViewComponents
|
|
9
|
+
# pulse/view_components root directory.
|
|
10
|
+
def self.root
|
|
11
|
+
Pathname(File.expand_path(File.join('..', '..'), __dir__))
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# @label Badge
|
|
5
|
+
class BadgePreview < ViewComponent::Preview
|
|
6
|
+
# @label Playground
|
|
7
|
+
#
|
|
8
|
+
# @param tag select {{ Pulse::Badge::TAG_OPTIONS }}
|
|
9
|
+
# @param scheme select {{ Pulse::Badge::SCHEME_OPTIONS }}
|
|
10
|
+
# @param variant select {{ Pulse::Badge::VARIANT_OPTIONS }}
|
|
11
|
+
def default(tag: :span, scheme: :secondary, variant: :standard)
|
|
12
|
+
render(
|
|
13
|
+
Pulse::Badge.new(tag:, scheme:, variant:)
|
|
14
|
+
) do
|
|
15
|
+
'Badge'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# @label Primary
|
|
20
|
+
def color_scheme_primary
|
|
21
|
+
render(Pulse::Badge.new(scheme: :primary)) { 'Primary' }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @label Secondary
|
|
25
|
+
def color_scheme_secondary
|
|
26
|
+
render(Pulse::Badge.new(scheme: :secondary)) { 'Secondary' }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @label Secondary Outline
|
|
30
|
+
def color_scheme_secondary_outline
|
|
31
|
+
render(Pulse::Badge.new(scheme: :secondary_outline)) do
|
|
32
|
+
'Secondary Outline'
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @label Invited
|
|
37
|
+
def color_scheme_success
|
|
38
|
+
render(Pulse::Badge.new(scheme: :invited)) { 'Invited' }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @label Active
|
|
42
|
+
def color_scheme_hidden
|
|
43
|
+
render(Pulse::Badge.new(scheme: :active)) { 'Active' }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @label Disabled
|
|
47
|
+
def color_scheme_failure
|
|
48
|
+
render(Pulse::Badge.new(scheme: :disabled)) { 'Disabled' }
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# @label BlankSlate
|
|
5
|
+
class BlankSlatePreview < ViewComponent::Preview
|
|
6
|
+
# @label Default options
|
|
7
|
+
def default
|
|
8
|
+
render Pulse::BlankSlate.new do |component|
|
|
9
|
+
component.with_title { 'Title' }
|
|
10
|
+
component.with_description { 'Description' }
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# @label BorderBox
|
|
5
|
+
class BorderBoxPreview < ViewComponent::Preview
|
|
6
|
+
# @label Default
|
|
7
|
+
def default
|
|
8
|
+
render(Pulse::BorderBox.new) do |component|
|
|
9
|
+
component.with_header { 'Header' }
|
|
10
|
+
component.with_body { 'Body' }
|
|
11
|
+
component.with_row { 'Row one' }
|
|
12
|
+
component.with_row { 'Row two' }
|
|
13
|
+
component.with_row { 'Row three' }
|
|
14
|
+
component.with_footer { 'Footer' }
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @label Body only
|
|
19
|
+
def body_only
|
|
20
|
+
render(Pulse::BorderBox.new) do |component|
|
|
21
|
+
component.with_body { 'Body' }
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @label Header with title
|
|
26
|
+
def header_with_title
|
|
27
|
+
render(Pulse::BorderBox.new) do |component|
|
|
28
|
+
component.with_header do |header|
|
|
29
|
+
header.with_title(tag: :h2) do
|
|
30
|
+
'Header with title'
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
component.with_body { 'Body' }
|
|
34
|
+
component.with_footer { 'Footer' }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# @label Row colors
|
|
39
|
+
def row_colors
|
|
40
|
+
render(Pulse::BorderBox.new) do |component|
|
|
41
|
+
component.with_row(scheme: :default) { 'Default' }
|
|
42
|
+
component.with_row(scheme: :neutral) { 'Neutral' }
|
|
43
|
+
component.with_row(scheme: :info) { 'Info' }
|
|
44
|
+
component.with_row(scheme: :warning) { 'Warning' }
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# :nodoc:
|
|
5
|
+
class BreadcrumbsPreview < ViewComponent::Preview
|
|
6
|
+
def default
|
|
7
|
+
render Pulse::Breadcrumbs.new do |c|
|
|
8
|
+
c.with_item(href: '/', text: 'Home')
|
|
9
|
+
c.with_item(text: 'Current Page')
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# :nodoc:
|
|
5
|
+
class ButtonPreview < ViewComponent::Preview
|
|
6
|
+
# @label Playground
|
|
7
|
+
# The default is :primary style
|
|
8
|
+
# @param label text
|
|
9
|
+
# @param url url
|
|
10
|
+
# @param scheme select {{ Pulse::Button::SCHEME_OPTIONS }}
|
|
11
|
+
# @param size select {{ Pulse::Button::SIZE_OPTIONS }}
|
|
12
|
+
# @param tag [Symbol] select [~, button]
|
|
13
|
+
# @param button_to [Boolean] select [~, true, false]
|
|
14
|
+
# @param disabled toggle
|
|
15
|
+
def playground(
|
|
16
|
+
label: 'Button',
|
|
17
|
+
scheme: Pulse::Button::DEFAULT_SCHEME,
|
|
18
|
+
size: Pulse::Button::DEFAULT_SIZE,
|
|
19
|
+
url: '#',
|
|
20
|
+
tag: :button,
|
|
21
|
+
button_to: false,
|
|
22
|
+
disabled: false
|
|
23
|
+
)
|
|
24
|
+
render(Pulse::Button.new(
|
|
25
|
+
label:,
|
|
26
|
+
scheme:,
|
|
27
|
+
size:,
|
|
28
|
+
url:,
|
|
29
|
+
tag:,
|
|
30
|
+
button_to:,
|
|
31
|
+
disabled:
|
|
32
|
+
))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @label Default
|
|
36
|
+
# @param label text
|
|
37
|
+
# @param size select {{ Pulse::Button::SIZE_OPTIONS }}
|
|
38
|
+
# @param disabled toggle
|
|
39
|
+
# @param tag select [a, summary, button]
|
|
40
|
+
def default(
|
|
41
|
+
label: 'Default',
|
|
42
|
+
size: Pulse::Button::DEFAULT_SIZE,
|
|
43
|
+
tag: :button,
|
|
44
|
+
disabled: false
|
|
45
|
+
)
|
|
46
|
+
render(Pulse::Button.new(
|
|
47
|
+
label:,
|
|
48
|
+
size:,
|
|
49
|
+
tag:,
|
|
50
|
+
disabled:
|
|
51
|
+
))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# @label Primary
|
|
55
|
+
# @param label text
|
|
56
|
+
# @param size select {{ Pulse::Button::SIZE_OPTIONS }}
|
|
57
|
+
# @param disabled toggle
|
|
58
|
+
# @param tag select [a, summary, button]
|
|
59
|
+
def primary(
|
|
60
|
+
label: 'Primary',
|
|
61
|
+
size: Pulse::Button::DEFAULT_SIZE,
|
|
62
|
+
tag: :button,
|
|
63
|
+
disabled: false
|
|
64
|
+
)
|
|
65
|
+
render(Pulse::Button.new(
|
|
66
|
+
label:,
|
|
67
|
+
scheme: :primary,
|
|
68
|
+
size:,
|
|
69
|
+
tag:,
|
|
70
|
+
disabled:
|
|
71
|
+
))
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# @label Secondary
|
|
75
|
+
# @param label text
|
|
76
|
+
# @param size select {{ Pulse::Button::SIZE_OPTIONS }}
|
|
77
|
+
# @param disabled toggle
|
|
78
|
+
# @param tag select [a, summary, button]
|
|
79
|
+
def secondary(
|
|
80
|
+
label: 'Secondary',
|
|
81
|
+
size: Pulse::Button::DEFAULT_SIZE,
|
|
82
|
+
tag: :button,
|
|
83
|
+
disabled: false
|
|
84
|
+
)
|
|
85
|
+
render(Pulse::Button.new(
|
|
86
|
+
label:,
|
|
87
|
+
scheme: :secondary,
|
|
88
|
+
size:,
|
|
89
|
+
tag:,
|
|
90
|
+
disabled:
|
|
91
|
+
))
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# @label Danger
|
|
95
|
+
# @param label text
|
|
96
|
+
# @param size select {{ Pulse::Button::SIZE_OPTIONS }}
|
|
97
|
+
# @param disabled toggle
|
|
98
|
+
# @param tag select [a, summary, button]
|
|
99
|
+
def danger(
|
|
100
|
+
label: 'Danger',
|
|
101
|
+
size: Pulse::Button::DEFAULT_SIZE,
|
|
102
|
+
tag: :button,
|
|
103
|
+
disabled: false
|
|
104
|
+
)
|
|
105
|
+
render(Pulse::Button.new(
|
|
106
|
+
label:,
|
|
107
|
+
scheme: :danger,
|
|
108
|
+
size:,
|
|
109
|
+
tag:,
|
|
110
|
+
disabled:
|
|
111
|
+
))
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# @label Button To
|
|
115
|
+
# @param label text
|
|
116
|
+
# @param url url
|
|
117
|
+
# @param scheme select {{ Pulse::Button::SCHEME_OPTIONS }}
|
|
118
|
+
# @param size select {{ Pulse::Button::SIZE_OPTIONS }}
|
|
119
|
+
# @param disabled toggle
|
|
120
|
+
def button_to(
|
|
121
|
+
label: 'Button to',
|
|
122
|
+
url: '#',
|
|
123
|
+
scheme: Pulse::Button::DEFAULT_SCHEME,
|
|
124
|
+
size: Pulse::Button::DEFAULT_SIZE,
|
|
125
|
+
disabled: false
|
|
126
|
+
)
|
|
127
|
+
render(Pulse::Button.new(
|
|
128
|
+
label:,
|
|
129
|
+
url:,
|
|
130
|
+
button_to: true,
|
|
131
|
+
scheme:,
|
|
132
|
+
size:,
|
|
133
|
+
disabled:
|
|
134
|
+
))
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# @label Counter
|
|
5
|
+
class CounterPreview < ViewComponent::Preview
|
|
6
|
+
# @label Playground
|
|
7
|
+
#
|
|
8
|
+
# @param count number
|
|
9
|
+
# @param scheme select {{ Pulse::Counter::SCHEME_OPTIONS }}
|
|
10
|
+
def playground(count: 10, scheme: :default)
|
|
11
|
+
render Pulse::Counter.new(count:, scheme:)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# @label Flash
|
|
5
|
+
class FlashPreview < ViewComponent::Preview
|
|
6
|
+
# @label Playground
|
|
7
|
+
#
|
|
8
|
+
# # @param full toggle
|
|
9
|
+
# # @param spacious toggle
|
|
10
|
+
# # @param dismissible toggle
|
|
11
|
+
# @param icon [Symbol] select [alert, check, info, people]
|
|
12
|
+
# @param scheme [Symbol] select [default, warning, danger, success]
|
|
13
|
+
# @param content text
|
|
14
|
+
def playground(full: false, spacious: false, dismissible: false,
|
|
15
|
+
icon: :people, scheme: Pulse::Flash::DEFAULT_SCHEME,
|
|
16
|
+
content: 'This is a flash message!')
|
|
17
|
+
render(Pulse::Flash.new(full:, spacious:,
|
|
18
|
+
dismissible:, icon:,
|
|
19
|
+
scheme:)) do
|
|
20
|
+
content
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @label Default
|
|
25
|
+
#
|
|
26
|
+
def default
|
|
27
|
+
render(Pulse::Flash.new) { 'This is a flash message!' }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @!group Color Schemes
|
|
31
|
+
#
|
|
32
|
+
# @label Default
|
|
33
|
+
def color_scheme_default
|
|
34
|
+
render(Pulse::Flash.new) { 'This is a flash message!' }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @label Warning
|
|
38
|
+
def color_scheme_warning
|
|
39
|
+
render(Pulse::Flash.new(scheme: :warning)) do
|
|
40
|
+
'This is a warning flash message!'
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @label Danger
|
|
45
|
+
def color_scheme_danger
|
|
46
|
+
render(Pulse::Flash.new(scheme: :danger)) do
|
|
47
|
+
'This is a danger flash message!'
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# @label Success
|
|
52
|
+
def color_scheme_success
|
|
53
|
+
render(Pulse::Flash.new(scheme: :success)) do
|
|
54
|
+
'This is a success flash message!'
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
#
|
|
58
|
+
# @!endgroup
|
|
59
|
+
|
|
60
|
+
# @!group More options
|
|
61
|
+
#
|
|
62
|
+
# @label Full width
|
|
63
|
+
# def options_full
|
|
64
|
+
# render(Pulse::Flash.new(full: true)) do
|
|
65
|
+
# 'This is a full width flash message!'
|
|
66
|
+
# end
|
|
67
|
+
# end
|
|
68
|
+
|
|
69
|
+
# @label Dismissible
|
|
70
|
+
# def options_dismissible
|
|
71
|
+
# render(Pulse::Flash.new(dismissible: true)) do
|
|
72
|
+
# 'This is a dismissible flash message!'
|
|
73
|
+
# end
|
|
74
|
+
# end
|
|
75
|
+
|
|
76
|
+
# @label With icon
|
|
77
|
+
def options_with_icon
|
|
78
|
+
render(Pulse::Flash.new(icon: :alert)) do
|
|
79
|
+
'This is a flash message with an icon!'
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
#
|
|
83
|
+
# @!endgroup
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# :nodoc:
|
|
5
|
+
class IconPreview < ViewComponent::Preview
|
|
6
|
+
# @label Playground
|
|
7
|
+
# @param icon [Symbol] select [alert, bookmark-slash, bookmark, check, close, dots-outline, gear, info, issue, mark-github, mark-jira, people, ruby, sort_asc, sort_desc, three-bars]
|
|
8
|
+
def playground(icon: :info)
|
|
9
|
+
render(Pulse::Icon.new(icon:))
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# @label Layout
|
|
5
|
+
class LayoutPreview < ViewComponent::Preview
|
|
6
|
+
# @label Playground
|
|
7
|
+
# @param first_in_source [Symbol] select [sidebar, main]
|
|
8
|
+
# @param gutter [Symbol] select [default, none, condensed, spacious]
|
|
9
|
+
def playground(first_in_source: :sidebar, gutter: :default)
|
|
10
|
+
render(
|
|
11
|
+
Pulse::Layout.new(gutter:, first_in_source:)
|
|
12
|
+
) do |component|
|
|
13
|
+
component.with_main(classes: 'pulse-bg-blue-50') do
|
|
14
|
+
'Main content'
|
|
15
|
+
end
|
|
16
|
+
component.with_sidebar(classes: 'pulse-bg-gray-50') do
|
|
17
|
+
'Sidebar content'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @label Default
|
|
23
|
+
def default
|
|
24
|
+
render(Pulse::Layout.new) do |component|
|
|
25
|
+
component.with_main(classes: 'pulse-bg-blue-50') do
|
|
26
|
+
'Main content'
|
|
27
|
+
end
|
|
28
|
+
component.with_sidebar(classes: 'pulse-bg-gray-50') do
|
|
29
|
+
'Sidebar content'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pulse
|
|
4
|
+
# :nodoc:
|
|
5
|
+
class LinkPreview < ViewComponent::Preview
|
|
6
|
+
# @label Playground
|
|
7
|
+
# @param href url
|
|
8
|
+
# @param content text
|
|
9
|
+
# @param scheme select {{ Pulse::Link::SCHEME_MAPPINGS.keys }}
|
|
10
|
+
# @param bold toggle
|
|
11
|
+
# @param underline toggle
|
|
12
|
+
# @param condition toggle
|
|
13
|
+
# @param classes text
|
|
14
|
+
def playground(href: 'https://example.com', content: 'Link text',
|
|
15
|
+
scheme: Pulse::Link::DEFAULT_SCHEME,
|
|
16
|
+
bold: false, underline: true, condition: true, classes: '')
|
|
17
|
+
render(
|
|
18
|
+
Pulse::Link.new(href:, scheme:, bold:,
|
|
19
|
+
underline:, condition:,
|
|
20
|
+
classes:)
|
|
21
|
+
) do
|
|
22
|
+
content
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# @label Default options
|
|
27
|
+
def default
|
|
28
|
+
render(Pulse::Link.new(href: 'https://example.com')) do
|
|
29
|
+
'Link text'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @label Leading visual
|
|
34
|
+
# @param href url
|
|
35
|
+
# @param content text
|
|
36
|
+
# @param scheme select {{ Pulse::Link::SCHEME_MAPPINGS.keys }}
|
|
37
|
+
# @param bold toggle
|
|
38
|
+
# @param underline toggle
|
|
39
|
+
# @param classes text
|
|
40
|
+
# @param icon text
|
|
41
|
+
def leading_visual(href: 'https://example.com', content: 'Link text',
|
|
42
|
+
scheme: Pulse::Link::DEFAULT_SCHEME,
|
|
43
|
+
bold: false, underline: false, condition: true,
|
|
44
|
+
icon: 'gear', classes: '')
|
|
45
|
+
render(
|
|
46
|
+
Pulse::Link.new(href:, scheme:, bold:,
|
|
47
|
+
underline:, condition:,
|
|
48
|
+
classes:)
|
|
49
|
+
) do |c|
|
|
50
|
+
c.with_leading_visual_icon(icon:)
|
|
51
|
+
content
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|