Class: Keystone::Ui::CodeComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Keystone::Ui::CodeComponent
- Defined in:
- app/components/keystone/ui/code_component.rb
Constant Summary collapse
- WRAPPER_CLASSES =
"overflow-hidden rounded-lg border border-surface-200 dark:border-surface-700"- CAPTION_CLASSES =
"border-b border-surface-200 bg-surface-50 px-4 py-2 font-mono text-xs text-surface-500 dark:border-surface-700 dark:bg-surface-800 dark:text-surface-400"- PRE_CLASSES =
"overflow-x-auto bg-surface-900 p-4 font-mono text-sm leading-relaxed text-surface-100 dark:bg-black"
Instance Attribute Summary collapse
-
#caption ⇒ Object
readonly
Returns the value of attribute caption.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
Instance Method Summary collapse
- #caption? ⇒ Boolean
- #caption_classes ⇒ Object
-
#initialize(language: nil, caption: nil) ⇒ CodeComponent
constructor
A new instance of CodeComponent.
- #language_class ⇒ Object
- #pre_classes ⇒ Object
- #wrapper_classes ⇒ Object
Constructor Details
#initialize(language: nil, caption: nil) ⇒ CodeComponent
Returns a new instance of CodeComponent.
12 13 14 15 |
# File 'app/components/keystone/ui/code_component.rb', line 12 def initialize(language: nil, caption: nil) @language = language @caption = caption end |
Instance Attribute Details
#caption ⇒ Object (readonly)
Returns the value of attribute caption.
10 11 12 |
# File 'app/components/keystone/ui/code_component.rb', line 10 def caption @caption end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
10 11 12 |
# File 'app/components/keystone/ui/code_component.rb', line 10 def language @language end |
Instance Method Details
#caption? ⇒ Boolean
17 18 19 |
# File 'app/components/keystone/ui/code_component.rb', line 17 def caption? !@caption.nil? end |
#caption_classes ⇒ Object
25 26 27 |
# File 'app/components/keystone/ui/code_component.rb', line 25 def caption_classes CAPTION_CLASSES end |
#language_class ⇒ Object
33 34 35 36 37 |
# File 'app/components/keystone/ui/code_component.rb', line 33 def language_class return nil if @language.nil? "language-#{@language}" end |
#pre_classes ⇒ Object
29 30 31 |
# File 'app/components/keystone/ui/code_component.rb', line 29 def pre_classes PRE_CLASSES end |
#wrapper_classes ⇒ Object
21 22 23 |
# File 'app/components/keystone/ui/code_component.rb', line 21 def wrapper_classes WRAPPER_CLASSES end |