Skip to content

Commit

Permalink
Merge pull request #432 from Vizzuality:fix/beta-level-style-feedback
Browse files Browse the repository at this point in the history
Add focus on the Proceed button on render
  • Loading branch information
Bluesmile82 authored Aug 18, 2023
2 parents 820b591 + e0fc0a7 commit ea19057
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
10 changes: 9 additions & 1 deletion app/assets/stylesheets/tpi/_mq_beta_scores.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
flex-direction: column;
}

&__container {
display: flex;
}

&__text {
color: white;
line-height: 40px;
Expand All @@ -15,7 +19,7 @@

&__divider {
margin: 0 15px 0 5px;
border-right: 1px solid rgba(255, 255, 255, 0.5);
border-right: 1px solid rgba(255, 255, 255, 0.2);

@include until($desktop) {
display: none;
Expand All @@ -36,5 +40,9 @@
&__download-button {
flex-grow: 4;
text-align: right;

@include until($desktop) {
margin-bottom: 10px;
}
}
}
8 changes: 8 additions & 0 deletions app/assets/stylesheets/tpi/pages/sectors-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
color: white;
line-height: 40px;
margin-right: 10px;

&.no-margin {
margin-right: 0;
}

&.weight-normal {
font-family: $family-sans-serif;
}
}

@include until($desktop) {
Expand Down
12 changes: 11 additions & 1 deletion app/javascript/components/tpi/MqBetaModal.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable operator-linebreak */
import React, { useState } from 'react';
import React, { useState, useRef, useEffect } from 'react';
import PropTypes from 'prop-types';
import CustomModal from './Modal';
import { OverlayProvider } from '@react-aria/overlays';
Expand All @@ -19,6 +19,15 @@ const MqBetaModal = ({ enabled, page }) => {
JSON.parse(isDismissed) || false
);

const mainButtonRef = useRef();

// Put focus on the Proceed button on render
useEffect(() => {
if (mainButtonRef.current) {
mainButtonRef.current.focus();
}
}, [mainButtonRef]);

if (popupDismissed || hasBeenShownInPage) {
return null;
}
Expand Down Expand Up @@ -84,6 +93,7 @@ const MqBetaModal = ({ enabled, page }) => {
type="button"
className="button is-primary"
onClick={handleOnRequestClose}
ref={mainButtonRef}
>
Proceed
</button>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tpi/companies/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div class="mq-beta-scores__download-button">
<%= link_to user_download_all_tpi_sectors_path, class: 'button is-primary is-pulled-right with-icon with-border' do %>
<img src="<%= asset_path 'icons/download.svg'%>" alt="download icon" />
Download All sectors data
Download data
<% end %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tpi/sectors/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div class="mq-beta-scores__download-button">
<%= link_to user_download_all_tpi_sectors_path, class: 'button is-primary with-icon with-border' do %>
<img src="<%= asset_path 'icons/download.svg'%>" alt="download icon" />
Download All sectors data
Download data
<% end %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tpi/sectors/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<div class="mq-beta-scores__download-button">
<%= link_to user_download_tpi_sector_path(@sector), class: 'button is-primary is-pulled-right with-icon with-border' do %>
<img src="<%= asset_path 'icons/download.svg'%>" alt="download icon" />
Download sector data
Download data
<% end %>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/tpi/shared/_mq_beta_scores.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div>
<div class="mq-beta-scores__container">
<span class="mq-beta-scores__text">MQ Methodology</span>
<%= link_to disable_beta_data_tpi_mq_assessments_path,
class: class_names('button', 'is-primary', 'with-border': !session[:enable_beta_mq_assessments]),
class: class_names('button', 'is-primary', 'no-margin', 'weight-normal': session[:enable_beta_mq_assessments], 'with-border': !session[:enable_beta_mq_assessments]),
style: "min-width: 0;" do %>
Current
<% end %>
Expand Down

0 comments on commit ea19057

Please sign in to comment.