Module: Vipassana::DesignStandardsHelper
- Defined in:
- lib/vipassana/design_standards_helper.rb
Instance Method Summary collapse
- #fix_locale(locale) ⇒ Object
- #is_rtl?(locale) ⇒ Boolean
- #vds_asset_url(path, localhost = false) ⇒ Object
- #vds_bootstrap_theme_css_tag(locale: I18n.locale, localhost: false) ⇒ Object
- #vds_bootstrap_theme_js_tag(locale: I18n.locale, localhost: false) ⇒ Object
- #vds_favicon_tag ⇒ Object
- #vds_icon_account ⇒ Object
-
#vds_icon_locale ⇒ Object
Some icons from bootstrap icons, so all websites use the same.
- #vds_icon_menu ⇒ Object
- #vds_logo(locale: I18n.locale, disposition: "default", size: '17', tagline: true, dark: false, use_english: true) ⇒ Object
Instance Method Details
#fix_locale(locale) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/vipassana/design_standards_helper.rb', line 5 def fix_locale(locale) locale = locale&.to_s&.downcase || "en" mapping = { 'zh' => 'zh-HANS', 'zh-hans' => 'zh-HANS', 'zh-hant'=> 'zh-HANT', 'zh-hant-hk'=> 'zh-HANT-HK', 'zh-hk' => 'zh-HANT-HK', 'zh-cn' => 'zh-HANS', 'zh-tw' => 'zh-HANT', } if mapping[locale].present? locale = mapping[locale] # zh-Hans -> zh-HANS else locale = locale.split("-").first # fr-CA -> fr end locale end |
#is_rtl?(locale) ⇒ Boolean
24 25 26 |
# File 'lib/vipassana/design_standards_helper.rb', line 24 def is_rtl?(locale) locale.to_sym.in? [:ar, :fa, :he] end |
#vds_asset_url(path, localhost = false) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/vipassana/design_standards_helper.rb', line 32 def vds_asset_url(path, localhost = false) return "http://localhost:5500/dist/#{path}" if localhost # For localhost dev, just run vscode liveserver version = Gem.loaded_specs['vipassana-design-standards'].version "https://cdn.jsdelivr.net/npm/vipassana-design-standards@#{version}/dist/#{path}" end |
#vds_bootstrap_theme_css_tag(locale: I18n.locale, localhost: false) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vipassana/design_standards_helper.rb', line 39 def vds_bootstrap_theme_css_tag(locale: I18n.locale, localhost: false) locale = fix_locale(locale) = [ stylesheet_link_tag(vds_asset_url("css/bootstrap5-theme#{is_rtl?(locale) ? '.rtl' : ''}.min.css", localhost)), ] # Add specific fonts for languages not compatible with Footlight and Noto Sans if locale.to_s.in? ['ar', 'fa', 'gu', 'he', 'ja', 'km', 'ko', 'or', 'si', 'ta', 'te', 'th', 'zh-HANS', 'zh-HANT', 'zh-HANT-HK'] << stylesheet_link_tag(vds_asset_url("css/fonts-#{locale}.min.css")) end .join.html_safe end |
#vds_bootstrap_theme_js_tag(locale: I18n.locale, localhost: false) ⇒ Object
52 53 54 55 |
# File 'lib/vipassana/design_standards_helper.rb', line 52 def vds_bootstrap_theme_js_tag(locale: I18n.locale, localhost: false) locale = fix_locale(locale) javascript_include_tag vds_asset_url("js/bootstrap5-theme.min.js", localhost) end |
#vds_favicon_tag ⇒ Object
28 29 30 |
# File 'lib/vipassana/design_standards_helper.rb', line 28 def vds_favicon_tag favicon_link_tag "https://cdn.jsdelivr.net/npm/vipassana-design-standards/dist/favicon.png" end |
#vds_icon_account ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/vipassana/design_standards_helper.rb', line 113 def vds_icon_account result = " <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"2.2em\" height=\"2.2em\" fill=\"currentColor\" class=\"bi bi-person-circle\" viewBox=\"0 0 16 16\">\n <path d=\"M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z\"/>\n <path fill-rule=\"evenodd\" d=\"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z\"/>\n </svg>\n HTML\n result.html_safe\nend\n" |
#vds_icon_locale ⇒ Object
Some icons from bootstrap icons, so all websites use the same
103 104 105 106 107 108 109 110 111 |
# File 'lib/vipassana/design_standards_helper.rb', line 103 def vds_icon_locale result = " <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1.2em\" height=\"1.2em\" fill=\"currentColor\" class=\"bi bi-translate\" viewBox=\"0 0 16 16\">\n <path d=\"M4.545 6.714 4.11 8H3l1.862-5h1.284L8 8H6.833l-.435-1.286H4.545zm1.634-.736L5.5 3.956h-.049l-.679 2.022H6.18z\"/>\n <path d=\"M0 2a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v3h3a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-3H2a2 2 0 0 1-2-2V2zm2-1a1 1 0 0 0-1 1v7a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H2zm7.138 9.995c.193.301.402.583.63.846-.748.575-1.673 1.001-2.768 1.292.178.217.451.635.555.867 1.125-.359 2.08-.844 2.886-1.494.777.665 1.739 1.165 2.93 1.472.133-.254.414-.673.629-.89-1.125-.253-2.057-.694-2.82-1.284.681-.747 1.222-1.651 1.621-2.757H14V8h-3v1.047h.765c-.318.844-.74 1.546-1.272 2.13a6.066 6.066 0 0 1-.415-.492 1.988 1.988 0 0 1-.94.31z\"/>\n </svg>\n HTML\n result.html_safe\nend\n" |
#vds_icon_menu ⇒ Object
123 124 125 126 127 128 129 130 |
# File 'lib/vipassana/design_standards_helper.rb', line 123 def result = " <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1.8em\" height=\"1.8em\" fill=\"currentColor\" class=\"bi bi-list\" viewBox=\"0 0 16 16\">\n <path fill-rule=\"evenodd\" d=\"M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z\"/>\n </svg>\n HTML\n result.html_safe\nend\n" |
#vds_logo(locale: I18n.locale, disposition: "default", size: '17', tagline: true, dark: false, use_english: true) ⇒ Object
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 |
# File 'lib/vipassana/design_standards_helper.rb', line 57 def vds_logo(locale: I18n.locale, disposition: "default", size: '17', tagline: true, dark: false, use_english: true) locale = fix_locale(locale) english_trans = VDS_TRANSLATIONS[:en] trans = VDS_TRANSLATIONS[locale.to_sym] || english_trans full_text = trans[:full] || "#{trans[:vipassana_meditation]} #{trans[:as_taught]} #{trans[:in_the_tradition]}" title = nil # Recommendation from trademark team : display logo in english, we can add translation on mouse hover if use_english && locale.to_sym != :en locale = :en trans = english_trans title = full_text end if disposition == "mobile" disposition = "left-two-lines" tagline = false end result = " <div class=\"vipassana-logo\"\n data-lang=\"\#{locale}\"\n data-disposition=\"\#{disposition}\"\n data-tagline=\"\#{tagline}\"\n data-dark-mode=\"\#{dark}\"\n data-reverse=\"\#{trans[:reverse]}\"\n title=\"\#{title}\"\n style=\"font-size: \#{size}px\">\n <img class=\"logo-wheel\" src=\"https://cdn.jsdelivr.net/npm/vipassana-design-standards/dist/dhamma-wheel.svg\" alt=\"\#{full_text}\" />\n <div class=\"logo-text\">\n <h1 class=\"logo-title\">\n <span data-start-with=\"\#{trans[:vipassana_meditation].at(0).downcase}\">\n \#{trans[:vipassana_meditation]}\n </span>\n <span class=\"logo-space\"> </span>\n <span>\#{trans[:as_taught]}</span>\n <span class=\"vipassana-as-taught\">\#{trans[:vipassana_as_taught]}</span>\n </h1>\n <div class=\"logo-subtitle\">\#{trans[:in_the_tradition]}</div>\n </div>\n </div>\n HTML\n result.html_safe\nend\n" |