vipassana-design-standards 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3dd1a91d3be43eab85fb6ae9cccc8c170a88b307992d3a874125ccbde7c2017
4
- data.tar.gz: 89658faacf65c9fa41d5e4d623371cbae455a562ee664b886a8fd31afbf8deb1
3
+ metadata.gz: b9d5376c299a9639b9cb0a1654795078034591398e8851f59a6ee261ee3283c8
4
+ data.tar.gz: 8f0169113e9b800aeaa25f6bd5b151d8ce325b1992c4269ca80a206bec80d428
5
5
  SHA512:
6
- metadata.gz: 959f43876597d8735d0b96c82f38306616d06c5f0f900259256de21cf9b794a3d01792b3aa026bfa5d9fbbebc85baade0325bf5a20fb6f8d40280b7d5f5351ad
7
- data.tar.gz: b79bed505bcc1a12b4b60897a589c528a59fe21e4909beda3c559cbd444679905739136db8a02ee71956cd8ebee12e2d85feb63c3cbe63a0f3e5337b00a29041
6
+ metadata.gz: c945dc8052f852e493411d14cc77e9c4b2c27122a9cf2d4ab00ecdbc114c38a00f714743def1af7923c8e3bd6476b0112f3f26ae9bc57f880ae755360528516a
7
+ data.tar.gz: 12fb1966c4b16e3454ba71e4e88113d828adafdc9eac59dbf149ee5e0e0c41d5c6f4d41fe90f43cb474c3e31efca817b87bb679721926d1e113d2da323b05f66
@@ -0,0 +1,111 @@
1
+ module Vipassana
2
+ module DesignStandardsHelper
3
+ require "vipassana/logos_inline_svg.rb"
4
+ require "vipassana/translations.rb"
5
+
6
+ def is_rtl?(locale)
7
+ locale.to_sym.in? [:ar, :fa, :he]
8
+ end
9
+
10
+ def vds_favicon_tag
11
+ favicon_link_tag "https://design-standards.dhamma.org/dist/favicon.png"
12
+ end
13
+
14
+ def vds_asset_url(path, localhost = false)
15
+ return "http://localhost:5500/dist/#{path}" if localhost # For localhost dev, just run vscode liveserver
16
+
17
+ version = Gem.loaded_specs['vipassana-design-standards'].version
18
+ "https://design-standards.dhamma.org/dist/#{version}/#{path}"
19
+ end
20
+
21
+ def vds_bootstrap_theme_css_tag(locale: I18n.locale, localhost: false)
22
+ tags = [
23
+ stylesheet_link_tag(vds_asset_url("css/bootstrap5-theme#{is_rtl?(locale) ? '.rtl' : ''}.min.css", localhost)),
24
+ ]
25
+ # Add specific fonts for languages not compatible with Footlight and Lato
26
+ if locale.to_sym.in? [:gu, :ja, :km]
27
+ tags << stylesheet_link_tag(vds_asset_url("css/fonts-#{locale}.min.css"))
28
+ end
29
+
30
+ tags.join.html_safe
31
+ end
32
+
33
+ def vds_bootstrap_theme_js_tag(locale: I18n.locale, localhost: false)
34
+ javascript_include_tag vds_asset_url("js/bootstrap.bundle.min.js", localhost)
35
+ end
36
+
37
+ def vds_logo_svg(locale: I18n.locale, disposition: "default", tagline: true, height: nil, width: nil)
38
+ height = 70 if height.nil? && width.nil?
39
+
40
+ data = VDS_SVGS[locale.to_sym] || VDS_SVGS[:en]
41
+ disposition += '-no-tagline' if tagline == false
42
+ string = data[disposition.to_sym] || data[:normal]
43
+
44
+ string.gsub!("<svg", "<svg height=\"#{height}\"") if height.present?
45
+ string.gsub!("<svg", "<svg width=\"#{width}\"") if width.present?
46
+
47
+ string.html_safe
48
+ end
49
+
50
+ def vds_logo_html(locale: I18n.locale, disposition: "default", size: '18', tagline: true, dark: false)
51
+ trans = VDS_TRANSLATIONS[locale.to_sym] || VDS_TRANSLATIONS[:en]
52
+
53
+ if disposition == "mobile"
54
+ disposition = "left-two-lines"
55
+ tagline = false
56
+ end
57
+
58
+ result = <<-HTML
59
+ <div class="vipassana-logo"
60
+ data-disposition="#{disposition}"
61
+ data-tagline="#{tagline}"
62
+ data-dark-mode="#{dark}"
63
+ data-reverse="#{trans[:reverse]}"
64
+ style="font-size: #{size}px">
65
+ <img class="logo-wheel" src="https://design-standards.dhamma.org/dist/dhamma-wheel.svg" />
66
+ <div class="logo-text">
67
+ <h1 class="logo-title">
68
+ <span data-start-with="#{trans[:vipassana_meditation].at(0).downcase}">
69
+ #{trans[:vipassana_meditation]}
70
+ </span>
71
+ <span class="logo-space">&nbsp;</span>
72
+ <span>#{trans[:as_taught]}</span>
73
+ </h1>
74
+ <div class="logo-subtitle">#{trans[:in_the_tradition]}</div>
75
+ </div>
76
+ </div>
77
+ HTML
78
+ result.html_safe
79
+ end
80
+
81
+ # Some icons from bootstrap icons, so all websites use the same
82
+ def vds_icon_locale
83
+ result = <<-HTML
84
+ <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">
85
+ <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"/>
86
+ <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"/>
87
+ </svg>
88
+ HTML
89
+ result.html_safe
90
+ end
91
+
92
+ def vds_icon_account
93
+ result = <<-HTML
94
+ <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">
95
+ <path d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"/>
96
+ <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"/>
97
+ </svg>
98
+ HTML
99
+ result.html_safe
100
+ end
101
+
102
+ def vds_icon_menu
103
+ result = <<-HTML
104
+ <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">
105
+ <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"/>
106
+ </svg>
107
+ HTML
108
+ result.html_safe
109
+ end
110
+ end
111
+ end