decidim-design 0.28.3 → 0.29.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/decidim/design/activities_helper.rb +23 -23
  3. data/app/helpers/decidim/design/address_helper.rb +45 -20
  4. data/app/helpers/decidim/design/announcement_helper.rb +45 -21
  5. data/app/helpers/decidim/design/application_helper.rb +28 -9
  6. data/app/helpers/decidim/design/author_helper.rb +57 -35
  7. data/app/helpers/decidim/design/buttons_helper.rb +67 -11
  8. data/app/helpers/decidim/design/cards_helper.rb +504 -64
  9. data/app/helpers/decidim/design/colors_helper.rb +33 -29
  10. data/app/helpers/decidim/design/follow_helper.rb +6 -17
  11. data/app/helpers/decidim/design/report_helper.rb +6 -13
  12. data/app/helpers/decidim/design/share_helper.rb +6 -13
  13. data/app/helpers/decidim/design/tab_panels_helper.rb +57 -13
  14. data/app/helpers/decidim/design/typography_helper.rb +4 -3
  15. data/app/packs/entrypoints/decidim_design.js +1 -0
  16. data/app/packs/stylesheets/_datepicker.scss +9 -0
  17. data/app/packs/stylesheets/design.scss +6 -0
  18. data/app/views/decidim/design/components/accordions.html.erb +19 -17
  19. data/app/views/decidim/design/components/activities/_static-activities.html.erb +1 -1
  20. data/app/views/decidim/design/components/activities/_static-activity.html.erb +1 -1
  21. data/app/views/decidim/design/components/activities.html.erb +1 -1
  22. data/app/views/decidim/design/components/address.html.erb +1 -1
  23. data/app/views/decidim/design/components/announcement.html.erb +1 -1
  24. data/app/views/decidim/design/components/author.html.erb +1 -1
  25. data/app/views/decidim/design/components/buttons.html.erb +2 -2
  26. data/app/views/decidim/design/components/cards/_static-card-l-extra-data-2.html.erb +1 -1
  27. data/app/views/decidim/design/components/cards/_static-card-l-image.html.erb +1 -1
  28. data/app/views/decidim/design/components/cards/_static-card-l.html.erb +1 -1
  29. data/app/views/decidim/design/components/cards.html.erb +1 -1
  30. data/app/views/decidim/design/components/dialogs.html.erb +21 -21
  31. data/app/views/decidim/design/components/dropdowns.html.erb +14 -14
  32. data/app/views/decidim/design/components/follow.html.erb +1 -1
  33. data/app/views/decidim/design/components/forms.html.erb +35 -21
  34. data/app/views/decidim/design/components/report.html.erb +1 -1
  35. data/app/views/decidim/design/components/share.html.erb +1 -1
  36. data/app/views/decidim/design/components/tab_panels.html.erb +1 -1
  37. data/app/views/decidim/design/components/tooltips.html.erb +104 -0
  38. data/app/views/decidim/design/foundations/accessibility.html.erb +41 -41
  39. data/app/views/decidim/design/foundations/color.html.erb +6 -3
  40. data/app/views/decidim/design/foundations/iconography.html.erb +4 -3
  41. data/app/views/decidim/design/foundations/layout.html.erb +31 -30
  42. data/app/views/decidim/design/foundations/typography.html.erb +2 -2
  43. data/app/views/decidim/design/home/index.html.erb +6 -6
  44. data/app/views/decidim/design/shared/_cell_call_textarea.html.erb +5 -0
  45. data/app/views/decidim/design/shared/_cell_snippet.html.erb +1 -3
  46. data/app/views/decidim/design/shared/_cell_table.html.erb +12 -0
  47. data/app/views/decidim/design/shared/_table.html.erb +1 -1
  48. data/config/locales/am-ET.yml +1 -0
  49. data/config/locales/ar.yml +7 -0
  50. data/config/locales/bg.yml +309 -0
  51. data/config/locales/ca.yml +309 -0
  52. data/config/locales/cs.yml +258 -0
  53. data/config/locales/da.yml +1 -0
  54. data/config/locales/de.yml +309 -0
  55. data/config/locales/el.yml +1 -0
  56. data/config/locales/en.yml +309 -0
  57. data/config/locales/eo.yml +1 -0
  58. data/config/locales/es-MX.yml +309 -0
  59. data/config/locales/es-PY.yml +309 -0
  60. data/config/locales/es.yml +309 -0
  61. data/config/locales/et.yml +1 -0
  62. data/config/locales/eu.yml +309 -0
  63. data/config/locales/fa-IR.yml +1 -0
  64. data/config/locales/fi-plain.yml +309 -0
  65. data/config/locales/fi.yml +309 -0
  66. data/config/locales/fr-CA.yml +309 -0
  67. data/config/locales/fr.yml +309 -0
  68. data/config/locales/ga-IE.yml +1 -0
  69. data/config/locales/gl.yml +1 -0
  70. data/config/locales/gn-PY.yml +1 -0
  71. data/config/locales/he-IL.yml +1 -0
  72. data/config/locales/hr.yml +1 -0
  73. data/config/locales/hu.yml +1 -0
  74. data/config/locales/id-ID.yml +1 -0
  75. data/config/locales/is-IS.yml +1 -0
  76. data/config/locales/it.yml +1 -0
  77. data/config/locales/ja.yml +309 -0
  78. data/config/locales/ka-GE.yml +1 -0
  79. data/config/locales/kaa.yml +1 -0
  80. data/config/locales/ko.yml +1 -0
  81. data/config/locales/lb.yml +1 -0
  82. data/config/locales/lo-LA.yml +1 -0
  83. data/config/locales/lt.yml +1 -0
  84. data/config/locales/lv.yml +1 -0
  85. data/config/locales/mt.yml +1 -0
  86. data/config/locales/nl.yml +1 -0
  87. data/config/locales/no.yml +9 -0
  88. data/config/locales/oc-FR.yml +1 -0
  89. data/config/locales/om-ET.yml +1 -0
  90. data/config/locales/pl.yml +309 -0
  91. data/config/locales/pt-BR.yml +1 -0
  92. data/config/locales/pt.yml +1 -0
  93. data/config/locales/ro-RO.yml +45 -0
  94. data/config/locales/ru.yml +1 -0
  95. data/config/locales/si-LK.yml +1 -0
  96. data/config/locales/sk.yml +1 -0
  97. data/config/locales/sl.yml +1 -0
  98. data/config/locales/so-SO.yml +1 -0
  99. data/config/locales/sq-AL.yml +1 -0
  100. data/config/locales/sr-CS.yml +1 -0
  101. data/config/locales/sv.yml +1 -0
  102. data/config/locales/sw-KE.yml +1 -0
  103. data/config/locales/th-TH.yml +1 -0
  104. data/config/locales/ti-ER.yml +1 -0
  105. data/config/locales/tr-TR.yml +78 -0
  106. data/config/locales/uk.yml +1 -0
  107. data/config/locales/val-ES.yml +1 -0
  108. data/config/locales/vi.yml +1 -0
  109. data/config/locales/zh-CN.yml +1 -0
  110. data/config/locales/zh-TW.yml +1 -0
  111. data/decidim-design.gemspec +1 -1
  112. data/lib/decidim/design/version.rb +1 -1
  113. metadata +77 -18
  114. data/app/views/decidim/design/components/address/_static-address-online.html.erb +0 -26
  115. data/app/views/decidim/design/components/address/_static-address-person.html.erb +0 -25
  116. data/app/views/decidim/design/components/author/_static-avatar.html.erb +0 -38
  117. data/app/views/decidim/design/components/author/_static-compact.html.erb +0 -46
  118. data/app/views/decidim/design/components/author/_static-default.html.erb +0 -35
  119. data/app/views/decidim/design/components/follow/_static-follow-default.html.erb +0 -4
  120. data/app/views/decidim/design/components/follow/_static-follow-unfollow.html.erb +0 -4
  121. data/app/views/decidim/design/components/report/_static-report.html.erb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da14464bdcbb72ff79780c4ecb697a75a1be73ad277918483cd123b1de4a57dd
4
- data.tar.gz: 4dee4ee881d1f03ba95e08847d4c2f7c16401bf073ff1e8a384f5051bc8e62a4
3
+ metadata.gz: 4af1cbd5a726cd380668994af88a6d8a8485741fe7179885331bd5e26a30824a
4
+ data.tar.gz: d3d79bd876604656fd248eb9b6e97db5617d11a48b86e3beeaddf93fa316cbdd
5
5
  SHA512:
6
- metadata.gz: c32ad7aa83233715ef99513016043454c15deb9027a17abd8d3d9ae46f07e885b8cfc531403903fb472fd6fb2b633dab2cadb3cd77b8bfd1eeee50ff38c83302
7
- data.tar.gz: a119ba3736552352e9ac19a6221e31e490775413e3bb49187be5a3383161a5e74e50773d7fab37e7adf2018b07b5818428c831917a289bad49f1b4e839f64cb8
6
+ metadata.gz: 495faab14fdfd9e2bccd36505acc1bf76824f48a40f702b77d4fa770ab4fbbe52a3fcd4779a7d584a6f04f830885a2864dd2a66b3fb07a8139b72986481eae9c
7
+ data.tar.gz: 0e859664089048cdd39ab2f5eb73cb899c3f937f655410551926e4c13098c81182bf25bcceb5a5635fa02677a4cec7c525430af0fc89ecfdb8fe680a23549ff8
@@ -6,29 +6,28 @@ module Decidim
6
6
  def activities_sections
7
7
  [
8
8
  {
9
- id: "demo",
9
+ id: t("decidim.design.helpers.demo"),
10
10
  contents: [
11
11
  {
12
12
  type: :text,
13
- values: ["This cell receives a model of LastActivity items and displays the following elements:"]
13
+ values: [t("decidim.design.helpers.demo_text")]
14
14
  },
15
15
  {
16
16
  type: :partial,
17
- template: "decidim/design/components/activities/static-activities"
17
+ template: "decidim/design/components/activities/static-activity"
18
18
  },
19
19
  {
20
20
  type: :text,
21
- values: ["Used by the last activity page, in a content block and within the dropdowns."]
21
+ values: [t("decidim.design.helpers.demo_text_2")]
22
22
  }
23
23
  ]
24
24
  },
25
25
  {
26
- id: "variations",
26
+ id: t("decidim.design.helpers.variations"),
27
27
  contents: [
28
28
  {
29
29
  type: :text,
30
- values: ["Regarding the type of activity, the cell could show different content, reporting the distinct resources,
31
- whether belong to a participatory space or not, has an author or not."]
30
+ values: [t("decidim.design.helpers.variations_text")]
32
31
  },
33
32
  {
34
33
  type: :partial,
@@ -37,29 +36,30 @@ module Decidim
37
36
  ]
38
37
  },
39
38
  {
40
- id: "sourcecode",
39
+ id: t("decidim.design.helpers.source_code"),
41
40
  contents: [
42
41
  {
43
- type: :table,
44
- options: { headings: %w(Cell Code) },
45
- items: activities_table(
46
- { name: "Activities", url: "https://github.com/decidim/decidim/blob/develop/decidim-core/app/cells/decidim/activities_cell.rb" },
47
- { name: "Activitiy", url: "https://github.com/decidim/decidim/blob/develop/decidim-core/app/cells/decidim/activity_cell.rb" }
48
- )
42
+ type: :cell_table,
43
+ options: { headings: [t("decidim.design.components.activities.activities")] },
44
+ cell_snippet: {
45
+ cell: "decidim/activities",
46
+ args: [Decidim::ActionLog.where(resource_type: "Decidim::ParticipatoryProcess", organization: current_organization).first(5)],
47
+ call_string: 'cell("decidim/activities", _ACTION_LOG_ITEMS_LIST)'
48
+ }
49
+ },
50
+ {
51
+ type: :cell_table,
52
+ options: { headings: [t("decidim.design.helpers.activity")] },
53
+ cell_snippet: {
54
+ cell: "decidim/activity",
55
+ args: [Decidim::ActionLog.where(resource_type: "Decidim::ParticipatoryProcess", organization: current_organization).last],
56
+ call_string: 'cell("decidim/activity", _ACTION_LOG_ITEM_)'
57
+ }
49
58
  }
50
59
  ]
51
60
  }
52
61
  ]
53
62
  end
54
-
55
- def activities_table(*table_rows, **_opts)
56
- table_rows.map do |table_cell|
57
- row = []
58
- row << table_cell[:name]
59
- row << link_to(table_cell[:url].split("/").last, table_cell[:url], target: "_blank", class: "text-secondary underline", rel: "noopener")
60
- row
61
- end
62
- end
63
63
  end
64
64
  end
65
65
  end
@@ -6,54 +6,79 @@ module Decidim
6
6
  def address_sections
7
7
  [
8
8
  {
9
- id: "demo",
9
+ id: t("decidim.design.helpers.demo"),
10
10
  contents: [
11
11
  {
12
12
  type: :text,
13
13
  values: [
14
- "Address cell receives a resource, and searches the geolocalizable attributes to render an specific markup."
14
+ t("decidim.design.helpers.address_description")
15
15
  ]
16
16
  },
17
17
  {
18
- type: :partial,
19
- template: "decidim/design/components/address/static-address-person"
18
+ values: cell("decidim/address", address_item)
20
19
  },
21
20
  {
22
21
  type: :text,
23
22
  values: [
24
- "Depending of the type of the content, the address could be an online url.
25
- For such cases, the displayed information is quite the same but shaped to fit."
23
+ t("decidim.design.helpers.address_description_2")
26
24
  ]
27
25
  },
28
26
  {
29
- type: :partial,
30
- template: "decidim/design/components/address/static-address-online"
27
+ values: cell("decidim/address", online_item, online: true)
31
28
  }
32
29
  ]
33
30
  },
34
31
  {
35
- id: "sourcecode",
32
+ id: t("decidim.design.helpers.source_code"),
36
33
  contents: [
37
34
  {
38
- type: :table,
39
- options: { headings: %w(Cell Code) },
40
- items: address_table(
41
- { name: "Address", url: "https://github.com/decidim/decidim/blob/develop/decidim-core/app/cells/decidim/address_cell.rb" }
42
- )
35
+ type: :text,
36
+ values: [""],
37
+ cell_snippet: {
38
+ cell: "decidim/address",
39
+ args: [address_item],
40
+ call_string: [
41
+ 'cell("decidim/address", _RESOURCE_)',
42
+ 'cell("decidim/address", _RESOURCE_, online: true)'
43
+ ]
44
+ }
43
45
  }
44
46
  ]
45
47
  }
46
48
  ]
47
49
  end
48
50
 
49
- def address_table(*table_rows, **_opts)
50
- table_rows.map do |table_cell|
51
- row = []
52
- row << table_cell[:name]
53
- row << link_to(table_cell[:url].split("/").last, table_cell[:url], target: "_blank", class: "text-secondary underline", rel: "noopener")
54
- row
51
+ def addressable_class
52
+ Class.new(ApplicationRecord) do
53
+ self.table_name = Decidim::Pages::Page.table_name
54
+
55
+ attr_accessor :organization, :location, :address, :latitude, :longitude, :online_meeting_url, :type_of_meeting, :start_time, :end_time
56
+
57
+ geocoded_by :address
55
58
  end
56
59
  end
60
+
61
+ def address_item
62
+ addressable_class.new(
63
+ organization: current_organization,
64
+ location: "Barcelona",
65
+ address: "Carrer del Pare Llaurador, 113",
66
+ latitude: 40.1234,
67
+ longitude: 2.1234,
68
+ start_time: 2.days.from_now,
69
+ end_time: 2.days.from_now + 4.hours
70
+ )
71
+ end
72
+
73
+ def online_item
74
+ addressable_class.new(
75
+ organization: current_organization,
76
+ type_of_meeting: "online",
77
+ online_meeting_url: "https://meet.jit.si/DecidimTry",
78
+ start_time: 2.days.from_now,
79
+ end_time: 2.days.from_now + 4.hours
80
+ )
81
+ end
57
82
  end
58
83
  end
59
84
  end
@@ -6,52 +6,76 @@ module Decidim
6
6
  def announcement_sections
7
7
  [
8
8
  {
9
- id: "callout_class",
9
+ title: t("decidim.design.helpers.callout_class"),
10
10
  contents: [
11
11
  {
12
12
  type: :text,
13
- values: ["This attribute applies an status to the announcement. By default, it uses secondary color."]
13
+ values: [t("decidim.design.helpers.callout_description")]
14
14
  },
15
15
  {
16
16
  type: :table,
17
- options: { headings: ["Announcement", "Callout class"] },
17
+ options: { headings: [t("decidim.design.components.announcement.title"), t("decidim.design.helpers.callout_class")] },
18
18
  items: announcement_table(
19
- { text: "I am an announcement", callout_class: nil },
20
- { text: "I am an announcement", callout_class: "alert" },
21
- { text: "I am an announcement", callout_class: "warning" },
22
- { text: "I am an announcement", callout_class: "success" }
19
+ { text: t("decidim.design.components.announcement.iam_an_announcement"), callout_class: "success" },
20
+ { text: t("decidim.design.components.announcement.iam_an_announcement"), callout_class: "warning" },
21
+ { text: t("decidim.design.components.announcement.iam_an_announcement"), callout_class: "alert" },
22
+ { text: t("decidim.design.components.announcement.iam_an_announcement"), callout_class: "secondary" },
23
+ { text: t("decidim.design.components.announcement.iam_an_announcement"), callout_class: nil }
23
24
  ),
24
25
  cell_snippet: {
25
26
  cell: "decidim/announcement",
26
- args: ["I am an annoucement"]
27
+ args: [t("decidim.design.components.announcement.iam_an_announcement"), { callout_class: "success" }],
28
+ call_string: [
29
+ 'cell("decidim/announcement", "I am an announcement", callout_class: "success")',
30
+ 'cell("decidim/announcement", "I am an announcement", callout_class: "warning")',
31
+ 'cell("decidim/announcement", "I am an announcement", callout_class: "alert")',
32
+ 'cell("decidim/announcement", "I am an announcement", callout_class: "secondary")',
33
+ 'cell("decidim/announcement", "I am an announcement")'
34
+ ]
27
35
  }
28
36
  }
29
37
  ]
30
38
  },
31
39
  {
32
- id: "plain_text_vs_hash",
40
+ title: t("decidim.design.helpers.plain_text_vs_hash"),
33
41
  contents: [
34
42
  {
35
43
  type: :text,
36
- values: ["You can provide as first argument both a plain text and a hash object"]
44
+ values: [t("decidim.design.helpers.plain_text_description")]
37
45
  },
38
46
  {
39
47
  type: :table,
40
- options: { headings: ["Announcement", "Callout class", "Argument"] },
48
+ options: { headings: [t("decidim.design.components.announcement.title"), t("decidim.design.helpers.callout_class"), t("decidim.design.helpers.argument")] },
41
49
  items: announcement_table(
42
- { text: "I am just plain text", callout_class: "secondary", argument: '"I am just plain text"' },
43
- { text: { title: "This is the title", body: "This is the body" }, callout_class: "secondary",
50
+ { text: { title: t("decidim.design.components.announcement.this_is_the_title"), body: t("decidim.design.components.announcement.this_is_the_body") },
51
+ callout_class: "success",
52
+ argument: '{ title: "This is the title", body: "This is the body" }, callout_class: "success"' },
53
+ { text: { title: t("decidim.design.components.announcement.this_is_the_title"), body: t("decidim.design.components.announcement.this_is_the_body") },
54
+ callout_class: "warning",
55
+ argument: '{ title: "This is the title", body: "This is the body" }, callout_class: "warning"' },
56
+ { text: { title: t("decidim.design.components.announcement.this_is_the_title"), body: t("decidim.design.components.announcement.this_is_the_body") },
57
+ callout_class: "alert",
58
+ argument: '{ title: "This is the title", body: "This is the body" }, callout_class: "alert"' },
59
+ { text: { title: t("decidim.design.components.announcement.this_is_the_title"), body: t("decidim.design.components.announcement.this_is_the_body") },
60
+ callout_class: "secondary",
61
+ argument: '{ title: "This is the title", body: "This is the body" }, callout_class: "secondary"' },
62
+ { text: { title: t("decidim.design.components.announcement.this_is_the_title"), body: t("decidim.design.components.announcement.this_is_the_body") },
63
+ callout_class: nil,
44
64
  argument: '{ title: "This is the title", body: "This is the body" }' },
45
- { text: { title: "This is the title", body: "This is the body" }, callout_class: "warning",
46
- argument: '{ text: { title: "This is the title", body: "This is the body" }, callout_class: "warning" }' },
47
- { text: { title: "This is the title", body: "This is the body" }, callout_class: "alert",
48
- argument: '{ text: { title: "This is the title", body: "This is the body" }, callout_class: "alert" }' },
49
- { text: { title: "This is the title", body: "This is the body" }, callout_class: "success",
50
- argument: '{ text: { title: "This is the title", body: "This is the body" }, callout_class: "success" }' }
65
+ { text: t("decidim.design.helpers.plain_text"), callout_class: nil, argument: '"I am just plain text"' }
51
66
  ),
52
67
  cell_snippet: {
53
68
  cell: "decidim/announcement",
54
- args: [{ title: "This is the title", body: "This is the body" }]
69
+ args: [{ title: t("decidim.design.components.announcement.this_is_the_title"), body: t("decidim.design.components.announcement.this_is_the_body") },
70
+ { callout_class: "success" }],
71
+ call_string: [
72
+ %{cell("decidim/announcement", { title: "This is the title", body: "This is the body" }, callout_class: "success")},
73
+ 'cell("decidim/announcement", { title: "This is the title", body: "This is the body" }, callout_class: "warning")',
74
+ 'cell("decidim/announcement", { title: "This is the title", body: "This is the body" }, callout_class: "alert")',
75
+ 'cell("decidim/announcement", { title: "This is the title", body: "This is the body" }, callout_class: "secondary")',
76
+ 'cell("decidim/announcement", { title: "This is the title", body: "This is the body" })',
77
+ 'cell("decidim/announcement", "I am just plain text")'
78
+ ]
55
79
  }
56
80
  }
57
81
  ]
@@ -63,7 +87,7 @@ module Decidim
63
87
  table_rows.each_with_index.map do |table_cell, _ix|
64
88
  row = []
65
89
  row << { method: :cell, args: ["decidim/announcement", table_cell[:text], { callout_class: table_cell[:callout_class] }] }
66
- row << table_cell[:callout_class] if table_cell[:callout_class].present?
90
+ row << table_cell[:callout_class]
67
91
  row << table_cell[:argument] if table_cell[:argument].present?
68
92
  row
69
93
  end
@@ -33,6 +33,8 @@ module Decidim
33
33
  html += content_tag(:p, value.html_safe, class: content[:class])
34
34
  end
35
35
  html.html_safe
36
+ when :cell_table
37
+ render partial: "decidim/design/shared/cell_table", locals: content.slice(:cell_snippet).merge(content[:options] || {})
36
38
  when :table
37
39
  render partial: "decidim/design/shared/table", locals: content.slice(:items).merge(content[:options] || {})
38
40
  when :partial
@@ -63,17 +65,34 @@ module Decidim
63
65
  def render_cell_snippet(content)
64
66
  return "" if content[:cell_snippet].blank?
65
67
 
66
- render partial: "decidim/design/shared/cell_snippet", locals: cell_snippet_locals(content[:cell_snippet][:cell], content[:cell_snippet][:args])
68
+ render partial: "decidim/design/shared/cell_snippet", locals: cell_snippet_locals(content[:cell_snippet])
67
69
  end
68
70
 
69
- def cell_snippet_locals(cell, args)
70
- path = args.delete(:path) || File.join("decidim-core/app/cells/", cell)
71
- {
72
- text: path,
73
- url: "https://github.com/decidim/decidim/blob/#{RELEASE_ID}/#{path}_cell.rb",
74
- cell:,
75
- args:
76
- }
71
+ def render_cell_call_textarea(cell_data)
72
+ render partial: "decidim/design/shared/cell_call_textarea", locals: cell_snippet_locals(cell_data)
73
+ end
74
+
75
+ def cell_snippet_locals(args)
76
+ path = args.delete(:path) || File.join("decidim-core/app/cells/", args[:cell])
77
+ url = "https://github.com/decidim/decidim/blob/#{RELEASE_ID}/#{path}_cell.rb"
78
+ call_string = args.delete(:call_string) || ""
79
+ args_texts = call_string.present? ? [] : inspect_args(args[:args])
80
+
81
+ args.merge(text: path, url:, call_string:, args_texts:)
82
+ end
83
+
84
+ def inspect_args(args = [])
85
+ return ["nil"] if args.blank?
86
+
87
+ args.map do |arg|
88
+ next arg.inspect if arg.is_a?(String)
89
+ next arg.except(:context).inspect if arg.is_a?(Hash)
90
+
91
+ class_name = arg.class.name
92
+ next "#{class_name}.take" if arg.is_a?(Decidim::ApplicationRecord)
93
+
94
+ class_name
95
+ end
77
96
  end
78
97
 
79
98
  def render_row(row)
@@ -6,86 +6,108 @@ module Decidim
6
6
  def author_sections
7
7
  [
8
8
  {
9
- id: "context",
9
+ title: t("decidim.design.helpers.context"),
10
10
  contents: [
11
11
  {
12
12
  type: :text,
13
13
  values: [
14
- "This cell display some information about a user. It a visual help to identify the resource/content creator.
15
- Hovering with the mouse displays a tooltip with further info and links to its profile",
16
- "For resources, this cell appears beneath the main heading. For other contents, it appears next to the content itself."
14
+ t("decidim.design.helpers.context_description"),
15
+ t("decidim.design.helpers.context_description_2")
17
16
  ]
18
17
  }
19
18
  ]
20
19
  },
21
20
  {
22
- id: "variations",
21
+ title: t("decidim.design.helpers.variations"),
23
22
  contents: [
24
23
  {
25
24
  type: :text,
26
- values: ["There are three different versions of this cell. Each one fits better regarding the context it is being displayed."]
25
+ values: [t("decidim.design.helpers.variations_description")]
27
26
  },
28
27
  {
29
- values: section_subtitle(title: "Default")
28
+ values: section_subtitle(title: t("decidim.design.helpers.default"))
30
29
  },
31
30
  {
32
- type: :partial,
33
- template: "decidim/design/components/author/static-default"
31
+ values: cell("decidim/author", user_item)
34
32
  },
35
33
  {
36
34
  type: :text,
37
- values: ["Calling the cell with no extra arguments, but the user itself."]
35
+ values: [t("decidim.design.helpers.default_description")]
38
36
  },
39
37
  {
40
- values: section_subtitle(title: "Compact")
38
+ values: section_subtitle(title: t("decidim.design.helpers.compact"))
41
39
  },
42
40
  {
43
- type: :partial,
44
- template: "decidim/design/components/author/static-compact"
41
+ values: cell("decidim/author", user_item, from: authored_item, context_actions: [:date], layout: :compact)
45
42
  },
46
43
  {
47
44
  type: :text,
48
- values: ["This author version is the common way to identify the resource creator."]
45
+ values: [t("decidim.design.helpers.compact_description")]
49
46
  },
50
47
  {
51
- values: section_subtitle(title: "Avatar")
48
+ values: section_subtitle(title: t("decidim.design.helpers.avatar"))
52
49
  },
53
50
  {
54
- type: :partial,
55
- template: "decidim/design/components/author/static-avatar"
51
+ values: cell("decidim/author", user_item, layout: :avatar)
56
52
  },
57
53
  {
58
54
  type: :text,
59
- values: ["It is used when there are narrow spaces, where the author is a secondary information."]
55
+ values: [t("decidim.design.helpers.avatar_description")]
60
56
  }
61
57
  ]
62
58
  },
63
59
  {
64
- id: "source_code",
60
+ title: t("decidim.design.helpers.source_code"),
65
61
  contents: [
66
- type: :table,
67
- options: { headings: %w(Card Code Usage) },
68
- items: author_table(
69
- { name: "Default", url: "https://github.com/decidim/decidim/tree/develop/decidim-core/app/cells/decidim/author",
70
- usage: "https://github.com/decidim/decidim/blob/develop/decidim-core/app/cells/decidim/card_l/author.erb" },
71
- { name: "Compact", url: "https://github.com/decidim/decidim/tree/develop/decidim-core/app/cells/decidim/author",
72
- usage: "https://github.com/decidim/decidim/blob/develop/decidim-blogs/app/views/decidim/blogs/posts/show.html.erb" },
73
- { name: "Avatar", url: "https://github.com/decidim/decidim/tree/develop/decidim-core/app/cells/decidim/author", usage: "https://github.com/decidim/decidim/blob/develop/decidim-core/app/cells/decidim/endorsers_list/show.erb" }
74
- )
62
+ {
63
+ type: :text,
64
+ values: [""],
65
+ cell_snippet: {
66
+ cell: "decidim/author",
67
+ args: [user_item],
68
+ call_string: [
69
+ 'cell("decidim/author", _USER_PRESENTER_)',
70
+ 'cell("decidim/author", _USER_PRESENTER_, from: _AUTHORABLE_OR_COAUTHORABLE_RESOURCE_, context_actions: [:date], layout: :compact)',
71
+ 'cell("decidim/author", _USER_PRESENTER_, layout: :avatar)'
72
+ ]
73
+ }
74
+ }
75
75
  ]
76
76
  }
77
77
  ]
78
78
  end
79
79
 
80
- def author_table(*table_rows, **_opts)
81
- table_rows.map do |table_cell|
82
- row = []
83
- row << table_cell[:name]
84
- row << link_to(table_cell[:url].split("/").last, table_cell[:url], target: "_blank", class: "text-secondary underline", rel: "noopener")
85
- row << link_to(table_cell[:usage].split("/").last, table_cell[:usage], target: "_blank", class: "text-secondary underline", rel: "noopener")
86
- row
80
+ def user_item
81
+ Decidim::User.new(
82
+ organization: current_organization,
83
+ id: 2000,
84
+ email: "alan_smith@example.org",
85
+ confirmed_at: Time.current,
86
+ name: "Alan Smith",
87
+ nickname: "alan_smith",
88
+ personal_url: "https://alan.example.org",
89
+ about: "Hi, I am Alan",
90
+ accepted_tos_version: Time.current
91
+ ).presenter
92
+ end
93
+
94
+ class AuthoredItem
95
+ ATTRS = [:published_at].freeze
96
+
97
+ attr_reader(*ATTRS)
98
+
99
+ def initialize(args = {})
100
+ args.slice(*ATTRS).each do |var, val|
101
+ instance_variable_set(:"@#{var}", val)
102
+ end
87
103
  end
88
104
  end
105
+
106
+ def authored_item
107
+ AuthoredItem.new(
108
+ published_at: 1.day.ago
109
+ )
110
+ end
89
111
  end
90
112
  end
91
113
  end