Class: Views::Docs::Select

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_ui/select/select_docs.rb

Instance Method Summary collapse

Methods inherited from Base

#Alert, #AlertDescription, #AlertTitle, #Heading, #InlineCode, #InlineLink, #Text, #component_files, #docs_accordion_path, #docs_alert_dialog_path, #docs_alert_path, #docs_aspect_ratio_path, #docs_avatar_path, #docs_badge_path, #docs_installation_path, #docs_separator_path, #docs_sheet_path

Instance Method Details

#view_templateObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/ruby_ui/select/select_docs.rb', line 4

def view_template
  component = "Select"

  div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
    render Docs::Header.new(title: "Select", description: "Displays a list of options for the user to pick from—triggered by a button.")

    Heading(level: 2) { "Usage" }

    render Docs::VisualCodeExample.new(title: "Select (Deconstructed)", context: self) do
      <<~RUBY
        Select(class: "w-56") do
          SelectInput(value: "apple", id: "select-a-fruit")

          SelectTrigger do
            SelectValue(placeholder: "Select a fruit", id: "select-a-fruit") { "Apple" }
          end

          SelectContent(outlet_id: "select-a-fruit") do
            SelectGroup do
              SelectLabel { "Fruits" }
              SelectItem(value: "apple") { "Apple" }
              SelectItem(value: "orange") { "Orange" }
              SelectItem(value: "banana") { "Banana" }
              SelectItem(value: "watermelon") { "Watermelon" }
            end
          end
        end
      RUBY
    end

    render Docs::VisualCodeExample.new(title: "Pre-selected Item", context: self) do
      <<~RUBY
        Select(class: "w-56") do
          SelectInput(value: "banana", id: "select-preselected-fruit")

          SelectTrigger do
            SelectValue(placeholder: "Select a fruit", id: "select-preselected-fruit") { "Banana" }
          end

          SelectContent(outlet_id: "select-preselected-fruit") do
            SelectGroup do
              SelectLabel { "Fruits" }
              SelectItem(value: "apple") { "Apple" }
              SelectItem(value: "orange") { "Orange" }
              SelectItem(value: "banana") { "Banana" }
              SelectItem(value: "watermelon") { "Watermelon" }
            end
          end
        end
      RUBY
    end

    render Docs::VisualCodeExample.new(title: "Disabled", context: self) do
      <<~RUBY
        Select(class: "w-56") do
          SelectInput(value: "apple", id: "select-a-fruit")

          SelectTrigger(disabled: true) do
            SelectValue(placeholder: "Select a fruit", id: "select-a-fruit") { "Apple" }
          end
        end
      RUBY
    end

    render Docs::VisualCodeExample.new(title: "Data Disabled", context: self) do
      <<~RUBY
        Select(class: "w-56") do
          SelectInput(value: "apple", id: "select-a-fruit")

          SelectTrigger do
            SelectValue(placeholder: "Select a fruit", id: "select-a-fruit") { "Apple" }
          end

          SelectContent(outlet_id: "select-a-fruit") do
            SelectGroup do
              SelectLabel { "Fruits" }
              SelectItem(data: {disabled: true}, value: "apple") { "Apple" }
              SelectItem(value: "orange") { "Orange" }
              SelectItem(value: "banana") { "Banana" }
              SelectItem(data: {disabled: true}, value: "watermelon") { "Watermelon" }
            end
          end
        end
      RUBY
    end

    render Docs::VisualCodeExample.new(title: "Aria Disabled Trigger", context: self) do
      <<~RUBY
        Select(class: "w-56") do
          SelectInput(value: "apple", id: "select-a-fruit")

          SelectTrigger(aria: {disabled: "true"}) do
            SelectValue(placeholder: "Select a fruit", id: "select-a-fruit") { "Apple" }
          end
        end
      RUBY
    end

    render Docs::VisualCodeExample.new(title: "Aria Disabled Item", context: self) do
      <<~RUBY
        Select(class: "w-56") do
          SelectInput(value: "apple", id: "select-a-fruit")

          SelectTrigger do
            SelectValue(placeholder: "Select a fruit", id: "select-a-fruit") { "Apple" }
          end

          SelectContent(outlet_id: "select-a-fruit") do
            SelectGroup do
              SelectLabel { "Fruits" }
              SelectItem(aria: {disabled: "true"}, value: "apple") { "Apple" }
              SelectItem(value: "orange") { "Orange" }
              SelectItem(value: "banana") { "Banana" }
              SelectItem(aria: {disabled: "true"}, value: "watermelon") { "Watermelon" }
            end
          end
        end
      RUBY
    end

    render Components::ComponentSetup::Tabs.new(component_name: component)

    render Docs::ComponentsTable.new(component_files(component))
  end
end