Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

fix: color contrast a11y (#133) #202

Closed
wants to merge 3 commits into from
Closed

fix: color contrast a11y (#133) #202

wants to merge 3 commits into from

Conversation

karthik1802
Copy link

@karthik1802 karthik1802 commented Oct 29, 2019

TSv2 Issue #135

Decouple border and text color of TemplateButton

Changes

  • Made changes in TemplateActions.js
    • Removed color from props in AddToContractBtn
    • Added new props(colorBorder, colorButton) in AddToContractBtn

Signed-off-by: karthik <karthikeyan@smartserv.io>
src/TemplateLibrary/TemplateActions.js Outdated Show resolved Hide resolved
src/TemplateLibrary/TemplateActions.js Outdated Show resolved Hide resolved
src/TemplateLibrary/TemplateActions.js Outdated Show resolved Hide resolved
src/TemplateLibrary/TemplateActions.js Outdated Show resolved Hide resolved
@jolanglinais
Copy link
Member

Also can you link to the issue @Michael-Grover made about this?

Signed-off-by: karthik <karthikeyan@smartserv.io>
@karthik1802
Copy link
Author

@irmerk @Michael-Grover I made the above changes

@jolanglinais jolanglinais added Difficulty: Starter Hacktoberfest by DigitalOcean and DEV Type: Enhancement ✨ Improvement to process or efficiency labels Oct 29, 2019
@jolanglinais
Copy link
Member

Sorry, my changes were actually wrong. I adjusted a bit:

import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { Icon } from 'semantic-ui-react';

const ActionsContainer = styled.div`
  padding: 0 !important;
  background-color: ${props => props.color || '#F9F9F9'} !important;
  max-height: 30px;
`;

const TemplateBtn = styled.a`
  padding: 5px 10px;
  display: inline-block;
  color: ${props => props.color || '#484848'};
  font-family: "IBM Plex Sans";
  font-size: 0.75em;
  font-weight: bold;
`;

const AddToContractBtn = styled(TemplateBtn)`
  width: 60%;
  border-right: 1px solid ${props => props.borderColor || '#E1E5EB'}; 
  cursor: pointer;
  &:hover {
    color: #3087CB;
  }
`;

const DetailsBtn = styled(TemplateBtn)`
  float: right;
  width: 40%;
  font-size: 0.75em;
  font-weight: 300;
  text-align: center;
`;

/**
 * A Template Actions component that will provide each template
 * with functionality.
 */
class TemplateActions extends React.Component {
  /**
     * Render this React component
     * @return {*} the react component
  */
  render() {
    const { handleViewDetails, libraryProps } = this.props;
    console.log('libraryProps: ', libraryProps);
    return (
        <ActionsContainer color={libraryProps.ACTION_BUTTON_BG}>
        <div>
          <AddToContractBtn
            className="adToContractButton"
            color={libraryProps.ACTION_BUTTON}
            borderColor={libraryProps.ACTION_BUTTON_BORDER}
            onClick={() => this.props.addToCont(this.props.uriKey)} >
            <Icon name="plus" />
            Add to contract
          </AddToContractBtn>
          <DetailsBtn
            color={libraryProps.ACTION_BUTTON}
            onClick={() => handleViewDetails(this.props.uriKey)}>
            Details
          </DetailsBtn>
        </div>
      </ActionsContainer>
    );
  }
}

/**
 * The property types for this component
 */
TemplateActions.propTypes = {
  addToCont: PropTypes.func,
  handleViewDetails: PropTypes.func,
  uriKey: PropTypes.string,
  libraryProps: PropTypes.shape({
    ACTION_BUTTON: PropTypes.string,
    ACTION_BUTTON_BG: PropTypes.string,
    ACTION_BUTTON_BORDER: PropTypes.string,
  }),
};

export default TemplateActions;

This makes this:

Screen Shot 2019-10-29 at 14 38 00 PM

Signed-off-by: karthik <karthikeyan@smartserv.io>
@karthik1802
Copy link
Author

@irmerk I made a small adjustment I guess this will give a similar result to #202 (comment)

@@ -5,22 +5,22 @@ import { Icon } from 'semantic-ui-react';

const ActionsContainer = styled.div`
padding: 0 !important;
background-color: ${props => props.color || '#F9F9F9'} !important;
background-color: ${props => props.ACTION_BUTTON || '#F9F9F9'} !important;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  background-color: ${props => props.color || '#F9F9F9'} !important;

max-height: 30px;
`;

const TemplateBtn = styled.a`
padding: 5px 10px;
display: inline-block;
color: ${props => props.color || '#484848'};
color: ${props => props.ACTION_BUTTON || '#484848'};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  color: ${props => props.color || '#484848'};

font-family: "IBM Plex Sans";
font-size: 0.75em;
font-weight: bold;
`;

const AddToContractBtn = styled(TemplateBtn)`
width: 60%;
border-right: 1px solid ${props => props.color || '#E1E5EB'};
border-right: 1px solid ${props => props.ACTION_BUTTON_BORDER || '#E1E5EB'};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  border-right: 1px solid ${props => props.borderColor || '#E1E5EB'}; 

@@ -49,7 +49,7 @@ class TemplateActions extends React.Component {
return (
<ActionsContainer color={libraryProps.ACTION_BUTTON_BG}>
<div>
<AddToContractBtn className="adToContractButton" color={libraryProps.ACTION_BUTTON_BORDER} onClick={() => this.props.addToCont(this.props.uriKey)} >
<AddToContractBtn className="adToContractButton" {...libraryProps} onClick={() => this.props.addToCont(this.props.uriKey)} >
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

            color={libraryProps.ACTION_BUTTON}
            borderColor={libraryProps.ACTION_BUTTON_BORDER}

@jolanglinais
Copy link
Member

I think you may have been on the right track in the beginning.

@karthik1802
Copy link
Author

hey!! sorry something came up couldn't reply, but in 79ea0ad I did the same(as in the second changes requested by you)

@jolanglinais
Copy link
Member

I think the changes I suggested since then should be the ones put in place here.

@jolanglinais
Copy link
Member

@akay1802 any progress on this?

@jolanglinais
Copy link
Member

Closing as stale, feel free to come back to it @akay1802!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Difficulty: Starter Hacktoberfest by DigitalOcean and DEV Type: Enhancement ✨ Improvement to process or efficiency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants