From a2574bb627a35fee2f7ba44f4e1c8b1b39601821 Mon Sep 17 00:00:00 2001 From: Jackson Pires Date: Fri, 13 Sep 2024 14:39:29 -0300 Subject: [PATCH 1/2] adjust docs to clipboard component --- app/controllers/docs_controller.rb | 4 +++ app/views/components/shared/menu.rb | 1 + app/views/docs/clipboard_view.rb | 33 +++++++++++++++++++ config/routes.rb | 1 + .../{phlex_ui => rbui}/clipboard_preview.rb | 8 ++--- 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 app/views/docs/clipboard_view.rb rename test/components/previews/{phlex_ui => rbui}/clipboard_preview.rb (62%) diff --git a/app/controllers/docs_controller.rb b/app/controllers/docs_controller.rb index c1757e8..6348b60 100644 --- a/app/controllers/docs_controller.rb +++ b/app/controllers/docs_controller.rb @@ -78,6 +78,10 @@ def checkbox render Docs::CheckboxView.new end + def clipboard + render Docs::ClipboardView.new + end + def codeblock render Docs::CodeblockView.new end diff --git a/app/views/components/shared/menu.rb b/app/views/components/shared/menu.rb index bbe5220..62c8643 100644 --- a/app/views/components/shared/menu.rb +++ b/app/views/components/shared/menu.rb @@ -72,6 +72,7 @@ def components {name: "Calendar", path: helpers.docs_calendar_path}, # { name: "Chart", path: helpers.docs_chart_path, badge: "New" }, {name: "Checkbox", path: helpers.docs_checkbox_path}, + {name: "Clipboard", path: helpers.docs_clipboard_path}, {name: "Codeblock", path: helpers.docs_codeblock_path}, {name: "Collapsible", path: helpers.docs_collapsible_path}, {name: "Combobox", path: helpers.docs_combobox_path}, diff --git a/app/views/docs/clipboard_view.rb b/app/views/docs/clipboard_view.rb new file mode 100644 index 0000000..37736de --- /dev/null +++ b/app/views/docs/clipboard_view.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class Docs::ClipboardView < ApplicationView + def view_template + div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do + render Docs::Header.new(title: "Clipboard", description: "A control to allow you to copy content to the clipboard.") + + TypographyH2 { "Usage" } + + render Docs::VisualCodeExample.new(title: "Example", context: self) do + <<~RUBY + Clipboard(success: "Copied!", error: "Copy failed!", class: "relative", options: {placement: "top"}) do + ClipboardSource(class: "hidden") { span { "Born rich!!!" } } + + ClipboardTrigger do + Link(href: "#", class: "gap-1") do + TypographyP(size: :small, class: "text-primary") { "Copy the secret of success!!!" } + end + end + end + RUBY + end + end + end + + private + + def components + [ + Docs::ComponentStruct.new(name: "Button", source: "https://github.com/PhlexUI/phlex_ui/blob/main/lib/phlex_ui/button.rb", built_using: :phlex) + ] + end +end diff --git a/config/routes.rb b/config/routes.rb index dc56b3b..eed62a4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,6 +27,7 @@ get "calendar", to: "docs#calendar", as: :docs_calendar get "chart", to: "docs#chart", as: :docs_chart get "checkbox", to: "docs#checkbox", as: :docs_checkbox + get "clipboard", to: "docs#clipboard", as: :docs_clipboard get "codeblock", to: "docs#codeblock", as: :docs_codeblock get "collapsible", to: "docs#collapsible", as: :docs_collapsible get "combobox", to: "docs#combobox", as: :docs_combobox diff --git a/test/components/previews/phlex_ui/clipboard_preview.rb b/test/components/previews/rbui/clipboard_preview.rb similarity index 62% rename from test/components/previews/phlex_ui/clipboard_preview.rb rename to test/components/previews/rbui/clipboard_preview.rb index 49ebe5a..2076b4b 100644 --- a/test/components/previews/phlex_ui/clipboard_preview.rb +++ b/test/components/previews/rbui/clipboard_preview.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true -module PhlexUi +module Rbui class ClipboardPreview < Lookbook::Preview # Default Clipboard # --------------- def default render(TestView.new) do - Clipboard(success: "Copiado!", error: "Falha ao copiar!", class: "relative") do - ClipboardSource(class: "hidden") { span { "Nascer herdeiro!!!" } } + Clipboard(success: "Copied!", error: "Copy failed!", class: "relative", options: {placement: "top"}) do + ClipboardSource(class: "hidden") { span { "Born rich!!!" } } ClipboardTrigger do Link(href: "#", class: "gap-1") do - TypographyP(size: :small, class: "text-primary") { "Copiar segredo do sucesso!!!" } + TypographyP(size: :small, class: "text-primary") { "Copy the secret of success!!!" } end end end From 30476a48f4cec84f0bf64a1fc14a0c0ae2af3ba2 Mon Sep 17 00:00:00 2001 From: Jackson Pires Date: Fri, 13 Sep 2024 14:44:59 -0300 Subject: [PATCH 2/2] adjust component files table --- app/views/docs/clipboard_view.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/docs/clipboard_view.rb b/app/views/docs/clipboard_view.rb index 37736de..5a7dbb0 100644 --- a/app/views/docs/clipboard_view.rb +++ b/app/views/docs/clipboard_view.rb @@ -20,6 +20,8 @@ def view_template end RUBY end + + render Docs::ComponentsTable.new(components) end end @@ -27,7 +29,11 @@ def view_template def components [ - Docs::ComponentStruct.new(name: "Button", source: "https://github.com/PhlexUI/phlex_ui/blob/main/lib/phlex_ui/button.rb", built_using: :phlex) + Docs::ComponentStruct.new(name: "ClipboarController", source: "https://github.com/PhlexUI/phlex_ui_stimulus/blob/main/controllers/clipboard_controller.js", built_using: :stimulus), + Docs::ComponentStruct.new(name: "ClipboardPopover", source: "https://github.com/PhlexUI/phlex_ui/blob/main/lib/phlex_ui/clipboard_popover.rb", built_using: :phlex), + Docs::ComponentStruct.new(name: "ClipboardSource", source: "https://github.com/PhlexUI/phlex_ui/blob/main/lib/phlex_ui/clipboard_source.rb", built_using: :phlex), + Docs::ComponentStruct.new(name: "ClipboardTrigger", source: "https://github.com/PhlexUI/phlex_ui/blob/main/lib/phlex_ui/clipboard_trigger.rb", built_using: :phlex), + Docs::ComponentStruct.new(name: "Clipboard", source: "https://github.com/PhlexUI/phlex_ui/blob/main/lib/phlex_ui/clipboard.rb", built_using: :phlex) ] end end