From 5696e41d03691da1b8eff8a280ff32a32ea34788 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 12 Sep 2019 13:55:20 -0300 Subject: [PATCH] estilo de los botones --- app/assets/stylesheets/application.scss | 25 ++++++++++ app/views/collaborations/collaborate.haml | 14 ++++-- app/views/i18n/_form.haml | 10 ++-- app/views/layouts/_breadcrumb.haml | 2 +- app/views/layouts/_btn_with_tooltip.haml | 2 +- app/views/posts/_submit.haml | 4 +- app/views/posts/index.haml | 6 +-- app/views/posts/show.haml | 2 +- app/views/posts/template_field/_table.haml | 58 ---------------------- app/views/sites/_form.haml | 8 +-- app/views/sites/fetch.haml | 2 +- app/views/sites/index.haml | 8 ++- app/views/usuaries/index.haml | 27 +++++----- app/views/usuaries/invite.haml | 2 +- 14 files changed, 70 insertions(+), 100 deletions(-) delete mode 100644 app/views/posts/template_field/_table.haml diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index ada55e38..568994a9 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -227,6 +227,26 @@ svg { } } +.btn { + background-color: $black; + color: $white; + border: none; + border-radius: 0; + + &:hover { + color: $white; + background-color: $magenta; + } + + &:active { + background-color: $magenta; + } + + &:focus { + box-shadow: 0 0 0 0.2rem $magenta; + } +} + .black-bg { color: $white; background-color: $black; @@ -246,6 +266,11 @@ svg { color: $black; border: none; + &:hover { + color: $black; + background-color: $cyan; + } + &:active { background-color: $cyan; } diff --git a/app/views/collaborations/collaborate.haml b/app/views/collaborations/collaborate.haml index f19cdef0..c935fc13 100644 --- a/app/views/collaborations/collaborate.haml +++ b/app/views/collaborations/collaborate.haml @@ -1,11 +1,14 @@ .row.align-items-center.justify-content-center.full-height .col-md-10.align-self-center - = raw CommonMarker.render_doc(@site.config.dig('welcome', 'message') || t('.welcome')).to_html + - welcome = @site.config.dig('welcome', 'message') || t('.welcome') + = sanitize_markdown welcome .col-md-6.align-self-center -# Copiado y pegado de app/views/devise/registrations/new.haml - resource = resource_name = @invitade - = form_for(resource, as: resource_name, url: site_collaborate_path(@site), method: :post) do |f| + = form_for(resource, as: resource_name, + url: site_collaborate_path(@site), + method: :post) do |f| - unless current_usuarie = render 'layouts/flash' .form-group @@ -15,10 +18,11 @@ .form-group = f.label :password - if @minimum_password_length - %em= t('devise.shared.minimum_password_length', count: @minimum_password_length) + %em + = t('devise.shared.minimum_password_length', + count: @minimum_password_length) = f.password_field :password, autocomplete: 'new-password', class: 'form-control' .form-group - - button = @site.config.dig('welcome', 'button') - = f.submit t('.submit'), class: 'btn btn-lg btn-primary btn-block', style: (button) ? "background-color: #{button};" : '' + = f.submit t('.submit'), class: 'btn btn-lg btn-block' diff --git a/app/views/i18n/_form.haml b/app/views/i18n/_form.haml index a1f25b00..c88e8616 100644 --- a/app/views/i18n/_form.haml +++ b/app/views/i18n/_form.haml @@ -11,7 +11,7 @@ = select_tag 'to', options_for_select(@options, @lang_to), class: 'form-control' - = submit_tag t('i18n.translate'), class: 'btn btn-info', name: nil + = submit_tag t('i18n.translate'), class: 'btn', name: nil - else = t('i18n.translating.from') = select_tag 'from', @@ -21,7 +21,7 @@ = select_tag 'to', options_for_select(@options, @lang_to), class: 'form-control' - = submit_tag t('i18n.change'), class: 'btn btn-info', name: nil + = submit_tag t('i18n.change'), class: 'btn', name: nil = render 'layouts/help', help: t('help.i18n.index') @@ -33,16 +33,16 @@ = hidden_field 'i18n', 'lang_to', value: @lang_to .form-group .dropdown.inline - %button.btn.btn-info.dropdown-toggle{type: 'button', + %button.btn.dropdown-toggle{type: 'button', data: { toggle: 'dropdown' }, aria: { haspopup: 'true', expanded: 'false' }} = t('i18n.jump') .dropdown-menu{aria: { labelledby: t('i18n.jump') }} - @site.data.dig(@lang_from).each_pair do |section, content| %a.dropdown-item{href: "##{section}"}= t("help.i18n.#{section}") - = submit_tag t('i18n.save'), class: 'btn btn-success' + = submit_tag t('i18n.save'), class: 'btn' = render 'i18n/recursive', data: @site.data.dig(@lang_from), superkeys: [] .form-group - = submit_tag t('i18n.save'), class: 'btn btn-success' + = submit_tag t('i18n.save'), class: 'btn' diff --git a/app/views/layouts/_breadcrumb.haml b/app/views/layouts/_breadcrumb.haml index a82383d4..0c5ae273 100644 --- a/app/views/layouts/_breadcrumb.haml +++ b/app/views/layouts/_breadcrumb.haml @@ -25,4 +25,4 @@ = link_to t('.mutual_aid'), mutual_aid_url(local_channel) %li.nav-item = link_to t('.logout'), destroy_usuarie_session_path, - method: :delete, role: 'button', class: 'btn btn-primary' + method: :delete, role: 'button', class: 'btn' diff --git a/app/views/layouts/_btn_with_tooltip.haml b/app/views/layouts/_btn_with_tooltip.haml index 897480bb..27eda3c1 100644 --- a/app/views/layouts/_btn_with_tooltip.haml +++ b/app/views/layouts/_btn_with_tooltip.haml @@ -1,2 +1,2 @@ -= link_to text, link, class: "btn btn-#{type || secondary}", += link_to text, link, class: 'btn', data: { toggle: 'tooltip' }, 'aria-role': 'button', title: tooltip diff --git a/app/views/posts/_submit.haml b/app/views/posts/_submit.haml index 438be23d..4346c7c1 100644 --- a/app/views/posts/_submit.haml +++ b/app/views/posts/_submit.haml @@ -1,9 +1,9 @@ .form-group - = submit_tag t('.save'), class: 'btn btn-success submit-post' + = submit_tag t('.save'), class: 'btn submit-post' -# Permitir guardar como borrador - if post.attributes.include? :draft = submit_tag t('.save_draft'), - class: 'btn btn-info submit-post-draft', + class: 'btn submit-post-draft', name: 'post[draft]' .invalid_help.alert.alert-danger.d-none = site.config.fetch('invalid_help', t('.invalid_help')) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 00f88b9a..cea14f96 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -13,7 +13,7 @@ .col .btn-group = link_to t('posts.new'), new_site_post_path(@site), - class: 'btn btn-success' + class: 'btn' .row .col @@ -50,11 +50,11 @@ - if policy(post).edit? = link_to t('posts.edit'), edit_site_post_path(@site, post.id), - class: 'btn btn-info' + class: 'btn' - if policy(post).destroy? = link_to t('posts.destroy'), site_post_path(@site, post.id), - class: 'btn btn-danger', + class: 'btn', method: :delete, data: { confirm: t('posts.confirm_destroy') } - else diff --git a/app/views/posts/show.haml b/app/views/posts/show.haml index a75c8e1b..0b493af7 100644 --- a/app/views/posts/show.haml +++ b/app/views/posts/show.haml @@ -9,7 +9,7 @@ %article.content = link_to t('posts.edit'), edit_site_post_path(@site, @post.id), - class: 'btn btn-info btn-block' + class: 'btn btn-block' %table.table.table-condensed.table-striped.table-responsive %thead diff --git a/app/views/posts/template_field/_table.haml b/app/views/posts/template_field/_table.haml deleted file mode 100644 index e6624b3d..00000000 --- a/app/views/posts/template_field/_table.haml +++ /dev/null @@ -1,58 +0,0 @@ --# Crea un contenedor para todos los campos agrupados -.field-groups{class: template.key} - -# Si es un array de valores, indicar a las usuarias que pueden - -# agregar más campos - - if template.array? - %small.text-muted= t('posts.table') - - -# El grupo individual, tenemos que crear uno si el post es nuevo, o - -# todos los que sean necesarios si estamos editando un post. - -# Obtenemos todos los valores. Puede ser un Hash o un Array - -# Creamos un array con un elemento solo para poder tener acceso a :each - - groups = @post.get_front_matter(name) - -# TODO volver a revisar cuando get_front_matter() tenga valores por defecto - - groups = [{}] unless groups - - if groups.is_a? Hash - - groups = [ groups ] - - groups.each_with_index do |group, i| - -# A partir del segundo grupo todos son extra - - classes = (i > 0) ? [template.key, 'extra'] : [template.key] - .field-group{class: classes.join(' ')} - -# Crear el botón de borrado si vamos a tener varias filas. - -# Luego por CSS ocultamos el primero. - - if template.array? - .clearfix - %button.btn.btn-warning.btn-sm.pull-right.remove-group{data: { group: template.key }} - = fa_icon 'close', title: t('posts.row.del', group: template.key.humanize) - = t('posts.row.del', group: template.key.humanize) - -# Separar los campos en dos columnas - - cols = template.cols || 2 - - template.nested_fields.each_slice(cols).to_a.each do |col| - .form-row{class: "align-items-#{template.align || 'start'}"} - - col.each do |nf| - - last = template.nested_fields.last == nf - - odd = (template.nested_fields.count % cols) != 0 - %div{class: (nf.nested? || (last && odd)) ? 'col-md-12' : "col-md-#{12/cols}"} - -# Si el template es un array, quiere decir que esperamos un array de hashes. - -# XXX usamos local_name para hacerlo recursivo y sumar el - -# name después, sin modificarlo recursivamente. - - if template.array? - - local_name = [i.to_s, nf.key] - - else - - local_name = [nf.key] - - if @post.new? - - value = nf.values - - else - -# Si el campo es un array, groups es un array de hashes - -# y group un hash. De lo contrarios, groups va a ser un - -# Hash - -# TODO cambiar por get_front_matter - - value = (template.array? || template.nested?) ? group[nf.key] : groups[nf.key] - = render 'posts/template_field/nested', - template: nf, - value: value, - name: [name, local_name].flatten - .extra-groups - - if template.array? - .clearfix - %button.btn.btn-success.btn-block.add-group{data: { group: template.key }}= t('posts.row.add', group: template.key.humanize) diff --git a/app/views/sites/_form.haml b/app/views/sites/_form.haml index e9a008aa..f12588ab 100644 --- a/app/views/sites/_form.haml +++ b/app/views/sites/_form.haml @@ -51,10 +51,10 @@ .btn-group{ role: 'group', 'aria-label': t('.design.actions') } - if design.url = link_to t('.design.url'), design.url, - target: '_blank', class: 'btn btn-info' + target: '_blank', class: 'btn' - if design.license = link_to t('.design.license'), design.license, - target: '_blank', class: 'btn btn-info' + target: '_blank', class: 'btn' %hr/ .form-group @@ -74,7 +74,7 @@ .btn-group{ role: 'group', 'aria-label': t('.licencia.actions') } = link_to t('.licencia.url'), licencia.url, - target: '_blank', class: 'btn btn-info' + target: '_blank', class: 'btn' %hr/ @@ -94,4 +94,4 @@ %hr/ .form-group - = f.submit submit, class: 'btn btn-success' + = f.submit submit, class: 'btn btn-lg btn-block' diff --git a/app/views/sites/fetch.haml b/app/views/sites/fetch.haml index 04d53853..224da18c 100644 --- a/app/views/sites/fetch.haml +++ b/app/views/sites/fetch.haml @@ -30,4 +30,4 @@ .row.justify-content-center .col-md-8 = link_to t('.merge.request'), site_pull_path(@site), - method: 'post', class: 'btn btn-lg btn-success' + method: 'post', class: 'btn btn-lg' diff --git a/app/views/sites/index.haml b/app/views/sites/index.haml index f96de4f1..a1055061 100644 --- a/app/views/sites/index.haml +++ b/app/views/sites/index.haml @@ -6,9 +6,7 @@ = t('sites.title') - if policy(Site).new? = link_to t('sites.new.title'), new_site_path, - class: 'btn btn-info' - - = render 'layouts/help', help: t('help.sites.index') + class: 'btn' %table.table.table-striped.table-condensed %tbody @@ -33,13 +31,13 @@ data: { toggle: 'tooltip' }, title: t('help.sites.invitations.accept'), method: :patch, - class: 'btn btn-success' + class: 'btn' = button_to t('sites.invitations.reject'), site_usuaries_reject_invitation_path(site), data: { toggle: 'tooltip' }, title: t('help.sites.invitations.reject'), method: :patch, - class: 'btn btn-info' + class: 'btn' - else - if policy(site).show? = render 'layouts/btn_with_tooltip', diff --git a/app/views/usuaries/index.haml b/app/views/usuaries/index.haml index 6a6c89b8..af7c6443 100644 --- a/app/views/usuaries/index.haml +++ b/app/views/usuaries/index.haml @@ -1,5 +1,5 @@ = render 'layouts/breadcrumb', - crumbs: [link_to(t('sites.index'), sites_path), + crumbs: [link_to(t('sites.index.title'), sites_path), @site.name, link_to(t('posts.index'), site_usuaries_path(@site))] @@ -13,21 +13,21 @@ -# Una tabla de usuaries y otra de invitades, con acciones - %i[usuaries invitades].each do |u| %h2 - = t(".#{u.to_s}") - .btn-group{role: 'group', 'aria-label': t('.actions')} + = t(".#{u}") + .btn-group{ role: 'group', 'aria-label': t('.actions') } - if @policy.invite? = link_to t('.invite'), site_usuaries_invite_path(@site, invite_as: u.to_s), - class: 'btn btn-success', + class: 'btn', data: { toggle: 'tooltip' }, title: t('.help.invite', invite_as: u.to_s) - if policy(Collaboration.new(@site)).collaborate? = link_to t('.public_invite'), site_collaborate_path(@site), - class: 'btn btn-info', + class: 'btn', data: { toggle: 'tooltip' }, title: t('.help.public_invite') - %p= t(".help.#{u.to_s}") + %p= t(".help.#{u}") %table.table.table-striped.table-condensed %tbody - @site.send(u).each do |cuenta| @@ -42,28 +42,29 @@ - if rol.temporal %span.badge.badge-info= t('.invited') %td - .btn-group{role: 'group', 'aria-label': t('.individual_actions')} + .btn-group{ role: 'group', + aria: { label: t('.individual_actions') } } - if @policy.demote? && @site.usuarie?(cuenta) = link_to t('.demote.text'), site_usuarie_demote_path(@site, cuenta), - class: 'btn btn-warning', + class: 'btn', data: { toggle: 'tooltip', - confirm: t('.demote.confirm')}, + confirm: t('.demote.confirm') }, title: t('.help.demote'), method: :patch - if @policy.promote? && @site.invitade?(cuenta) = link_to t('.promote.text'), site_usuarie_promote_path(@site, cuenta), - class: 'btn btn-success', + class: 'btn', data: { toggle: 'tooltip', - confirm: t('.promote.confirm')}, + confirm: t('.promote.confirm') }, title: t('.help.promote'), method: :patch - if @policy.destroy? = link_to t('.destroy.text'), site_usuarie_path(@site, cuenta), - class: 'btn btn-danger', + class: 'btn', data: { toggle: 'tooltip', - confirm: t('.destroy.confirm')}, + confirm: t('.destroy.confirm') }, title: t('.help.destroy'), method: :delete diff --git a/app/views/usuaries/invite.haml b/app/views/usuaries/invite.haml index 16a2614b..a205b2e4 100644 --- a/app/views/usuaries/invite.haml +++ b/app/views/usuaries/invite.haml @@ -21,4 +21,4 @@ invite_as: invite_as) = f.text_area :invitaciones, class: 'form-control' .form-group - = f.submit t('.submit'), class: 'btn btn-success' + = f.submit t('.submit'), class: 'btn'