decidim-design 0.28.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +29 -0
- data/Rakefile +3 -0
- data/app/controllers/concerns/decidim/design/has_templates.rb +20 -0
- data/app/controllers/decidim/design/application_controller.rb +28 -0
- data/app/controllers/decidim/design/components_controller.rb +21 -0
- data/app/controllers/decidim/design/foundations_controller.rb +14 -0
- data/app/controllers/decidim/design/home_controller.rb +11 -0
- data/app/helpers/decidim/design/activities_helper.rb +65 -0
- data/app/helpers/decidim/design/address_helper.rb +59 -0
- data/app/helpers/decidim/design/announcement_helper.rb +73 -0
- data/app/helpers/decidim/design/application_helper.rb +100 -0
- data/app/helpers/decidim/design/author_helper.rb +91 -0
- data/app/helpers/decidim/design/buttons_helper.rb +148 -0
- data/app/helpers/decidim/design/cards_helper.rb +195 -0
- data/app/helpers/decidim/design/colors_helper.rb +96 -0
- data/app/helpers/decidim/design/follow_helper.rb +42 -0
- data/app/helpers/decidim/design/iconography_helper.rb +72 -0
- data/app/helpers/decidim/design/report_helper.rb +38 -0
- data/app/helpers/decidim/design/share_helper.rb +38 -0
- data/app/helpers/decidim/design/tab_panels_helper.rb +103 -0
- data/app/helpers/decidim/design/typography_helper.rb +112 -0
- data/app/packs/entrypoints/decidim_design.js +2 -0
- data/app/packs/stylesheets/design.scss +121 -0
- data/app/views/decidim/design/components/accordions.html.erb +66 -0
- data/app/views/decidim/design/components/activities/_static-activities.html.erb +79 -0
- data/app/views/decidim/design/components/activities/_static-activity.html.erb +56 -0
- data/app/views/decidim/design/components/activities.html.erb +11 -0
- data/app/views/decidim/design/components/address/_static-address-online.html.erb +9 -0
- data/app/views/decidim/design/components/address/_static-address-person.html.erb +8 -0
- data/app/views/decidim/design/components/address.html.erb +11 -0
- data/app/views/decidim/design/components/announcement.html.erb +11 -0
- data/app/views/decidim/design/components/author/_static-avatar.html.erb +38 -0
- data/app/views/decidim/design/components/author/_static-compact.html.erb +46 -0
- data/app/views/decidim/design/components/author/_static-default.html.erb +35 -0
- data/app/views/decidim/design/components/author.html.erb +11 -0
- data/app/views/decidim/design/components/buttons.html.erb +15 -0
- data/app/views/decidim/design/components/cards/_static-card-g-highlight.html.erb +18 -0
- data/app/views/decidim/design/components/cards/_static-card-g-metadata-2.html.erb +17 -0
- data/app/views/decidim/design/components/cards/_static-card-g-metadata.html.erb +14 -0
- data/app/views/decidim/design/components/cards/_static-card-g.html.erb +17 -0
- data/app/views/decidim/design/components/cards/_static-card-l-description.html.erb +28 -0
- data/app/views/decidim/design/components/cards/_static-card-l-extra-data-2.html.erb +31 -0
- data/app/views/decidim/design/components/cards/_static-card-l-extra-data.html.erb +16 -0
- data/app/views/decidim/design/components/cards/_static-card-l-image.html.erb +66 -0
- data/app/views/decidim/design/components/cards/_static-card-l-meetings.html.erb +30 -0
- data/app/views/decidim/design/components/cards/_static-card-l.html.erb +60 -0
- data/app/views/decidim/design/components/cards/_static-card-s.html.erb +15 -0
- data/app/views/decidim/design/components/cards.html.erb +11 -0
- data/app/views/decidim/design/components/dialogs.html.erb +89 -0
- data/app/views/decidim/design/components/dropdowns.html.erb +64 -0
- data/app/views/decidim/design/components/follow/_static-follow-default.html.erb +4 -0
- data/app/views/decidim/design/components/follow/_static-follow-unfollow.html.erb +4 -0
- data/app/views/decidim/design/components/follow.html.erb +11 -0
- data/app/views/decidim/design/components/forms.html.erb +235 -0
- data/app/views/decidim/design/components/report/_static-report.html.erb +34 -0
- data/app/views/decidim/design/components/report.html.erb +11 -0
- data/app/views/decidim/design/components/share.html.erb +11 -0
- data/app/views/decidim/design/components/tab_panels.html.erb +11 -0
- data/app/views/decidim/design/foundations/accessibility.html.erb +99 -0
- data/app/views/decidim/design/foundations/color/_table.html.erb +26 -0
- data/app/views/decidim/design/foundations/color.html.erb +16 -0
- data/app/views/decidim/design/foundations/iconography/_icons.html.erb +8 -0
- data/app/views/decidim/design/foundations/iconography.html.erb +16 -0
- data/app/views/decidim/design/foundations/layout.html.erb +128 -0
- data/app/views/decidim/design/foundations/typography.html.erb +15 -0
- data/app/views/decidim/design/home/index.html.erb +17 -0
- data/app/views/decidim/design/shared/_card_grid.html.erb +3 -0
- data/app/views/decidim/design/shared/_cell_snippet.html.erb +6 -0
- data/app/views/decidim/design/shared/_sections.html.erb +9 -0
- data/app/views/decidim/design/shared/_table.html.erb +12 -0
- data/app/views/layouts/decidim/design/_head.html.erb +5 -0
- data/app/views/layouts/decidim/design/_layout.html.erb +86 -0
- data/app/views/layouts/decidim/design/application.html.erb +15 -0
- data/config/assets.rb +8 -0
- data/config/routes.rb +10 -0
- data/lib/decidim/design/engine.rb +35 -0
- data/lib/decidim/design/version.rb +9 -0
- data/lib/decidim/design.rb +10 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 33ba30809afe60f670af1852d42a7907b8be469ffe0258758bc7fcdb44f6e33e
|
4
|
+
data.tar.gz: 4d7b5f2110a21492e55f0f572e37aba6aff86d4bb14cf3cb837ad7e042c381f9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 11afb8f8ebd15a40f3ee4fe64b47c9d634737df2184ed923b4a700ac71ade1c50bf2f17effe21b6e85d844a082febf0a2d989e6accd3f529f77978d680035ea2
|
7
|
+
data.tar.gz: 2d479847014f448709b316fe3136522f8091f6bc60a2f495d3f6542e232ca021a8e4b8c3b5a40dcce15c17b3456b36351b7eea2be4dd3492e1525bbd9ffeb4f3
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# decidim-design
|
2
|
+
|
3
|
+
The Design module implements the design guide for Decidim, a guide that includes all information related with the design of the platform.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
The design application index is available at `/design` path
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'decidim-design'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
See [Decidim](https://github.com/decidim/decidim).
|
26
|
+
|
27
|
+
## License
|
28
|
+
|
29
|
+
See [Decidim](https://github.com/decidim/decidim).
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Design
|
7
|
+
# Common logic of design controllers
|
8
|
+
module HasTemplates
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
def show
|
13
|
+
raise ActionController::RoutingError, "Not Found" unless lookup_context.exists?("decidim/design/#{controller_name}/#{params[:id]}")
|
14
|
+
|
15
|
+
render "decidim/design/#{controller_name}/#{params[:id]}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Design
|
5
|
+
class ApplicationController < ::DecidimController
|
6
|
+
include NeedsOrganization
|
7
|
+
|
8
|
+
helper Decidim::MetaTagsHelper
|
9
|
+
|
10
|
+
helper_method :path_items
|
11
|
+
|
12
|
+
def path_items(path)
|
13
|
+
files = Dir.glob("#{gem_path}/app/views/decidim/design/#{path}/*.html.erb")
|
14
|
+
|
15
|
+
files.map do |file|
|
16
|
+
name = File.basename(file, ".html.erb")
|
17
|
+
{ name:, path: send("#{path.singularize}_path", name) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def gem_path
|
24
|
+
@gem_path ||= Bundler.load.specs.find { |spec| spec.name == "decidim-design" }.full_gem_path
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Design
|
5
|
+
class ComponentsController < Decidim::Design::ApplicationController
|
6
|
+
include Decidim::ControllerHelpers
|
7
|
+
include Decidim::Design::HasTemplates
|
8
|
+
|
9
|
+
helper ButtonsHelper
|
10
|
+
helper CardsHelper
|
11
|
+
helper ShareHelper
|
12
|
+
helper AnnouncementHelper
|
13
|
+
helper AuthorHelper
|
14
|
+
helper ActivitiesHelper
|
15
|
+
helper TabPanelsHelper
|
16
|
+
helper ReportHelper
|
17
|
+
helper AddressHelper
|
18
|
+
helper FollowHelper
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Design
|
5
|
+
class FoundationsController < Decidim::Design::ApplicationController
|
6
|
+
include Decidim::ControllerHelpers
|
7
|
+
include Decidim::Design::HasTemplates
|
8
|
+
|
9
|
+
helper ColorsHelper
|
10
|
+
helper TypographyHelper
|
11
|
+
helper IconographyHelper
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Design
|
5
|
+
module ActivitiesHelper
|
6
|
+
def activities_sections
|
7
|
+
[
|
8
|
+
{
|
9
|
+
id: "demo",
|
10
|
+
contents: [
|
11
|
+
{
|
12
|
+
type: :text,
|
13
|
+
values: ["This cell receives a model of LastActivity items and displays the following elements:"]
|
14
|
+
},
|
15
|
+
{
|
16
|
+
type: :partial,
|
17
|
+
template: "decidim/design/components/activities/static-activities"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
type: :text,
|
21
|
+
values: ["Used by the last activity page, in a content block and within the dropdowns."]
|
22
|
+
}
|
23
|
+
]
|
24
|
+
},
|
25
|
+
{
|
26
|
+
id: "variations",
|
27
|
+
contents: [
|
28
|
+
{
|
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."]
|
32
|
+
},
|
33
|
+
{
|
34
|
+
type: :partial,
|
35
|
+
template: "decidim/design/components/activities/static-activity"
|
36
|
+
}
|
37
|
+
]
|
38
|
+
},
|
39
|
+
{
|
40
|
+
id: "sourcecode",
|
41
|
+
contents: [
|
42
|
+
{
|
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
|
+
)
|
49
|
+
}
|
50
|
+
]
|
51
|
+
}
|
52
|
+
]
|
53
|
+
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
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Design
|
5
|
+
module AddressHelper
|
6
|
+
def address_sections
|
7
|
+
[
|
8
|
+
{
|
9
|
+
id: "demo",
|
10
|
+
contents: [
|
11
|
+
{
|
12
|
+
type: :text,
|
13
|
+
values: [
|
14
|
+
"Address cell receives a resource, and searches the geolocalizable attributes to render an specific markup."
|
15
|
+
]
|
16
|
+
},
|
17
|
+
{
|
18
|
+
type: :partial,
|
19
|
+
template: "decidim/design/components/address/static-address-person"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
type: :text,
|
23
|
+
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."
|
26
|
+
]
|
27
|
+
},
|
28
|
+
{
|
29
|
+
type: :partial,
|
30
|
+
template: "decidim/design/components/address/static-address-online"
|
31
|
+
}
|
32
|
+
]
|
33
|
+
},
|
34
|
+
{
|
35
|
+
id: "sourcecode",
|
36
|
+
contents: [
|
37
|
+
{
|
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
|
+
)
|
43
|
+
}
|
44
|
+
]
|
45
|
+
}
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
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
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Design
|
5
|
+
module AnnouncementHelper
|
6
|
+
def announcement_sections
|
7
|
+
[
|
8
|
+
{
|
9
|
+
id: "callout_class",
|
10
|
+
contents: [
|
11
|
+
{
|
12
|
+
type: :text,
|
13
|
+
values: ["This attribute applies an status to the announcement. By default, it uses secondary color."]
|
14
|
+
},
|
15
|
+
{
|
16
|
+
type: :table,
|
17
|
+
options: { headings: ["Announcement", "Callout class"] },
|
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" }
|
23
|
+
),
|
24
|
+
cell_snippet: {
|
25
|
+
cell: "decidim/announcement",
|
26
|
+
args: ["I am an annoucement"]
|
27
|
+
}
|
28
|
+
}
|
29
|
+
]
|
30
|
+
},
|
31
|
+
{
|
32
|
+
id: "plain_text_vs_hash",
|
33
|
+
contents: [
|
34
|
+
{
|
35
|
+
type: :text,
|
36
|
+
values: ["You can provide as first argument both a plain text and a hash object"]
|
37
|
+
},
|
38
|
+
{
|
39
|
+
type: :table,
|
40
|
+
options: { headings: ["Announcement", "Callout class", "Argument"] },
|
41
|
+
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",
|
44
|
+
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" }' }
|
51
|
+
),
|
52
|
+
cell_snippet: {
|
53
|
+
cell: "decidim/announcement",
|
54
|
+
args: [{ title: "This is the title", body: "This is the body" }]
|
55
|
+
}
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
def announcement_table(*table_rows, **_opts)
|
63
|
+
table_rows.each_with_index.map do |table_cell, _ix|
|
64
|
+
row = []
|
65
|
+
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?
|
67
|
+
row << table_cell[:argument] if table_cell[:argument].present?
|
68
|
+
row
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Design
|
5
|
+
module ApplicationHelper
|
6
|
+
include Decidim::IconHelper
|
7
|
+
|
8
|
+
# For the moment keep this as a constant and later decide where to move
|
9
|
+
# this
|
10
|
+
RELEASE_ID = "develop"
|
11
|
+
|
12
|
+
def section_title(section)
|
13
|
+
content_tag(:h2, section_text(section))
|
14
|
+
end
|
15
|
+
|
16
|
+
def section_subtitle(section)
|
17
|
+
content_tag(:h3, section_text(section))
|
18
|
+
end
|
19
|
+
|
20
|
+
def section_text(section)
|
21
|
+
title = section[:title] || section[:id]&.titleize
|
22
|
+
return title if section[:label].blank?
|
23
|
+
|
24
|
+
title += content_tag(:span, section[:label], class: "label")
|
25
|
+
title.html_safe
|
26
|
+
end
|
27
|
+
|
28
|
+
def render_content(content)
|
29
|
+
case content[:type]
|
30
|
+
when :text
|
31
|
+
html = ""
|
32
|
+
content[:values].each do |value|
|
33
|
+
html += content_tag(:p, value.html_safe, class: content[:class])
|
34
|
+
end
|
35
|
+
html.html_safe
|
36
|
+
when :table
|
37
|
+
render partial: "decidim/design/shared/table", locals: content.slice(:items).merge(content[:options] || {})
|
38
|
+
when :partial
|
39
|
+
partial = render_partial(content)
|
40
|
+
|
41
|
+
return partial if content[:layout].blank?
|
42
|
+
|
43
|
+
render layout: content[:layout] do
|
44
|
+
partial.html_safe
|
45
|
+
end
|
46
|
+
else
|
47
|
+
content[:values].to_s.html_safe
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def render_partial(content)
|
52
|
+
if content[:template].is_a?(Array)
|
53
|
+
templates = ""
|
54
|
+
content[:template].each do |value|
|
55
|
+
templates += render partial: value, locals: content[:locals]
|
56
|
+
end
|
57
|
+
return templates
|
58
|
+
end
|
59
|
+
|
60
|
+
render partial: content[:template], locals: content[:locals]
|
61
|
+
end
|
62
|
+
|
63
|
+
def render_cell_snippet(content)
|
64
|
+
return "" if content[:cell_snippet].blank?
|
65
|
+
|
66
|
+
render partial: "decidim/design/shared/cell_snippet", locals: cell_snippet_locals(content[:cell_snippet][:cell], content[:cell_snippet][:args])
|
67
|
+
end
|
68
|
+
|
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
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def render_row(row)
|
80
|
+
if row.is_a?(Array)
|
81
|
+
html = ""
|
82
|
+
row.each do |cell|
|
83
|
+
html += render_cell(cell)
|
84
|
+
end
|
85
|
+
html.html_safe
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def render_cell(cell)
|
90
|
+
content_tag(:td) do
|
91
|
+
if cell.is_a?(Hash)
|
92
|
+
send(cell[:method], *cell[:args]).to_s
|
93
|
+
else
|
94
|
+
cell
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Design
|
5
|
+
module AuthorHelper
|
6
|
+
def author_sections
|
7
|
+
[
|
8
|
+
{
|
9
|
+
id: "context",
|
10
|
+
contents: [
|
11
|
+
{
|
12
|
+
type: :text,
|
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."
|
17
|
+
]
|
18
|
+
}
|
19
|
+
]
|
20
|
+
},
|
21
|
+
{
|
22
|
+
id: "variations",
|
23
|
+
contents: [
|
24
|
+
{
|
25
|
+
type: :text,
|
26
|
+
values: ["There are three different versions of this cell. Each one fits better regarding the context it is being displayed."]
|
27
|
+
},
|
28
|
+
{
|
29
|
+
values: section_subtitle(title: "Default")
|
30
|
+
},
|
31
|
+
{
|
32
|
+
type: :partial,
|
33
|
+
template: "decidim/design/components/author/static-default"
|
34
|
+
},
|
35
|
+
{
|
36
|
+
type: :text,
|
37
|
+
values: ["Calling the cell with no extra arguments, but the user itself."]
|
38
|
+
},
|
39
|
+
{
|
40
|
+
values: section_subtitle(title: "Compact")
|
41
|
+
},
|
42
|
+
{
|
43
|
+
type: :partial,
|
44
|
+
template: "decidim/design/components/author/static-compact"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
type: :text,
|
48
|
+
values: ["This author version is the common way to identify the resource creator."]
|
49
|
+
},
|
50
|
+
{
|
51
|
+
values: section_subtitle(title: "Avatar")
|
52
|
+
},
|
53
|
+
{
|
54
|
+
type: :partial,
|
55
|
+
template: "decidim/design/components/author/static-avatar"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
type: :text,
|
59
|
+
values: ["It is used when there are narrow spaces, where the author is a secondary information."]
|
60
|
+
}
|
61
|
+
]
|
62
|
+
},
|
63
|
+
{
|
64
|
+
id: "source_code",
|
65
|
+
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
|
+
)
|
75
|
+
]
|
76
|
+
}
|
77
|
+
]
|
78
|
+
end
|
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
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Design
|
5
|
+
module ButtonsHelper
|
6
|
+
def buttons_sections
|
7
|
+
[
|
8
|
+
{
|
9
|
+
id: "sizes",
|
10
|
+
contents: [
|
11
|
+
{
|
12
|
+
type: :table,
|
13
|
+
options: buttons_table_options,
|
14
|
+
items: buttons_table_items_from_args(
|
15
|
+
{ button_classes: "button button__primary button__xs" },
|
16
|
+
{ button_classes: "button button__primary button__sm" },
|
17
|
+
{ button_classes: "button button__primary button__lg" },
|
18
|
+
{ button_classes: "button button__primary button__xl" }
|
19
|
+
),
|
20
|
+
cell_snippet: { cell: "decidim/button", args: [{ text: "Send" }, { button_classes: "button button__primary button__xs" }] }
|
21
|
+
}
|
22
|
+
]
|
23
|
+
},
|
24
|
+
{
|
25
|
+
id: "colors",
|
26
|
+
contents: [
|
27
|
+
{
|
28
|
+
type: :table,
|
29
|
+
options: buttons_table_options,
|
30
|
+
items: buttons_table_items_from_args(
|
31
|
+
{ button_classes: "button button__lg button__primary" },
|
32
|
+
{ button_classes: "button button__lg button__secondary" },
|
33
|
+
{ button_classes: "button button__lg button__tertiary" }
|
34
|
+
),
|
35
|
+
cell_snippet: { cell: "decidim/button", args: [{ text: "Send" }, { button_classes: "button button__lg button__primary" }] }
|
36
|
+
}
|
37
|
+
]
|
38
|
+
},
|
39
|
+
{
|
40
|
+
id: "transparent",
|
41
|
+
contents: [
|
42
|
+
{
|
43
|
+
type: :table,
|
44
|
+
options: buttons_table_options,
|
45
|
+
items: buttons_table_items_from_args(
|
46
|
+
{ button_classes: "button button__lg button__transparent-primary" },
|
47
|
+
{ button_classes: "button button__lg button__transparent-secondary" },
|
48
|
+
{ button_classes: "button button__lg button__transparent-tertiary" }
|
49
|
+
),
|
50
|
+
cell_snippet: { cell: "decidim/button", args: [{ text: "Send" }, { button_classes: "button button__lg button__transparent-primary" }] }
|
51
|
+
},
|
52
|
+
{
|
53
|
+
type: :text,
|
54
|
+
values: ["In case of a darker background:"]
|
55
|
+
},
|
56
|
+
{
|
57
|
+
type: :table,
|
58
|
+
options: buttons_table_options,
|
59
|
+
items: buttons_table_items_from_args(
|
60
|
+
{ button_classes: "button button__lg button__transparent" },
|
61
|
+
background: true
|
62
|
+
),
|
63
|
+
cell_snippet: { cell: "decidim/button", args: [{ text: "Send" }, { button_classes: "button button__lg button__transparent" }] }
|
64
|
+
}
|
65
|
+
]
|
66
|
+
},
|
67
|
+
{
|
68
|
+
id: "text",
|
69
|
+
contents: [
|
70
|
+
{
|
71
|
+
type: :table,
|
72
|
+
options: buttons_table_options,
|
73
|
+
items: buttons_table_items_from_args(
|
74
|
+
{ button_classes: "button button__lg button__text" },
|
75
|
+
{ button_classes: "button button__lg button__text-primary" },
|
76
|
+
{ button_classes: "button button__lg button__text-secondary" },
|
77
|
+
{ button_classes: "button button__lg button__text-tertiary" }
|
78
|
+
),
|
79
|
+
cell_snippet: { cell: "decidim/button", args: [{ text: "Send" }, { button_classes: "button button__lg button__text" }] }
|
80
|
+
}
|
81
|
+
]
|
82
|
+
},
|
83
|
+
{
|
84
|
+
id: "icons",
|
85
|
+
contents: [
|
86
|
+
{
|
87
|
+
type: :table,
|
88
|
+
options: buttons_table_options,
|
89
|
+
items: buttons_table_items_from_args(
|
90
|
+
{ button_classes: "button button__lg button__secondary", icon: "question-line" },
|
91
|
+
{ button_classes: "button button__lg button__transparent-secondary", icon: "question-line" }
|
92
|
+
),
|
93
|
+
cell_snippet: { cell: "decidim/button", args: [{ text: "Send", icon: "question-line" }, { button_classes: "button button__lg button__secondary" }] }
|
94
|
+
}
|
95
|
+
]
|
96
|
+
},
|
97
|
+
{
|
98
|
+
id: "disabled",
|
99
|
+
contents: [
|
100
|
+
{
|
101
|
+
type: :table,
|
102
|
+
options: buttons_table_options,
|
103
|
+
items: buttons_table_items_from_args(
|
104
|
+
{
|
105
|
+
button_classes: "button button__lg button__secondary",
|
106
|
+
html_options: { disabled: true },
|
107
|
+
description: "<code>disabled</code> data-attribute present".html_safe
|
108
|
+
}
|
109
|
+
),
|
110
|
+
cell_snippet: {
|
111
|
+
cell: "decidim/button",
|
112
|
+
args: [
|
113
|
+
{ text: "Send" },
|
114
|
+
{ button_classes: "button button__lg button__secondary", html_options: { disabled: true } }
|
115
|
+
]
|
116
|
+
}
|
117
|
+
}
|
118
|
+
]
|
119
|
+
}
|
120
|
+
]
|
121
|
+
end
|
122
|
+
|
123
|
+
def button_row(button_args)
|
124
|
+
[
|
125
|
+
{ method: :cell, args: ["decidim/button", button_args.slice(:icon).merge(text: "Send"), button_args] },
|
126
|
+
button_args[:description] || button_args[:button_classes]
|
127
|
+
]
|
128
|
+
end
|
129
|
+
|
130
|
+
def background_button_row(button_args)
|
131
|
+
[
|
132
|
+
content_tag(:div, cell("decidim/button", button_args.slice(:icon_name).merge(text: "Send"), button_args), class: "bg-primary p-4 rounded"),
|
133
|
+
button_args[:description] || button_args[:button_classes]
|
134
|
+
]
|
135
|
+
end
|
136
|
+
|
137
|
+
def buttons_table_items_from_args(*buttons_args, **opts)
|
138
|
+
buttons_args.map do |button_args|
|
139
|
+
opts[:background] ? background_button_row(button_args) : button_row(button_args)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def buttons_table_options
|
144
|
+
@buttons_table_options ||= { headings: %w(Button Classes) }
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|