Skip to content

Commit 41aa9e5

Browse files
committed
Add MaskedInput component
1 parent de9cbea commit 41aa9e5

4 files changed

Lines changed: 51 additions & 0 deletions

File tree

app/controllers/docs_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ def link
134134
render Docs::LinkView.new
135135
end
136136

137+
def masked_input
138+
render Docs::MaskedInputView.new
139+
end
140+
137141
def pagination
138142
render Docs::PaginationView.new
139143
end

app/views/components/shared/menu.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def components
8686
{name: "Input", path: helpers.docs_input_path},
8787
{name: "Hover Card", path: helpers.docs_hover_card_path},
8888
{name: "Link", path: helpers.docs_link_path},
89+
{name: "Masked Input", path: helpers.masked_input_path},
8990
{name: "Pagination", path: helpers.docs_pagination_path, badge: "New"},
9091
{name: "Popover", path: helpers.docs_popover_path},
9192
{name: "Select", path: helpers.docs_select_path, badge: "New"},
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# frozen_string_literal: true
2+
3+
class Docs::MaskedInputView < ApplicationView
4+
def view_template
5+
component = "MaskedInput"
6+
7+
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
8+
render Docs::Header.new(title: "MaskedInput", description: "Displays a form input field with applied mask.")
9+
10+
Heading(level: 2) { "Usage" }
11+
12+
Text do
13+
plain "For advanced usage, check out the "
14+
InlineLink(href: "https://beholdr.github.io/maska/v3", target: "_blank") { "Maska website" }
15+
plain "."
16+
end
17+
18+
render Docs::VisualCodeExample.new(title: "Phone number", context: self) do
19+
<<~RUBY
20+
div(class: 'grid w-full max-w-sm items-center gap-1.5') do
21+
MaskedInput(data: {maska: "(##) #####-####"})
22+
end
23+
RUBY
24+
end
25+
26+
render Docs::VisualCodeExample.new(title: "Hex color code", context: self) do
27+
<<~RUBY
28+
div(class: 'grid w-full max-w-sm items-center gap-1.5') do
29+
MaskedInput(data: {maska: "!#HHHHHH", maska_tokens: "H:[0-9a-fA-F]"})
30+
end
31+
RUBY
32+
end
33+
34+
render Docs::VisualCodeExample.new(title: "CPF / CNPJ", context: self) do
35+
<<~RUBY
36+
div(class: 'grid w-full max-w-sm items-center gap-1.5') do
37+
MaskedInput(data: {maska: "['###.###.###-##', '##.###.###/####-##']"})
38+
end
39+
RUBY
40+
end
41+
42+
render Docs::ComponentsTable.new(component_references(component, Docs::VisualCodeExample.collected_code), component_files(component))
43+
end
44+
end
45+
end

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
get "hover_card", to: "docs#hover_card", as: :docs_hover_card
4242
get "input", to: "docs#input", as: :docs_input
4343
get "link", to: "docs#link", as: :docs_link
44+
get "masked_input", to: "docs#masked_input", as: :masked_input
4445
get "pagination", to: "docs#pagination", as: :docs_pagination
4546
get "popover", to: "docs#popover", as: :docs_popover
4647
get "select", to: "docs#select", as: :docs_select

0 commit comments

Comments
 (0)