UdacityMobileWebScholarship / showcase-app

This application is a collaborative project made by the Google Udacity Mobile Web Specialist Scholars.
13 stars 30 forks source link

Fixes some styles of the Tile component #63

Closed blenderskool closed 6 years ago

blenderskool commented 6 years ago

Fixes #62

Checklist

Changes proposed in this pull request:

saini-himanshu commented 6 years ago

Also just adding color:backgroundColor in styles adds the box-shadow color as background

const tileStyles = {
backgroundColor,
color:backgroundColor,
}

where we can keep box-shadow as box-shadow: 0px 0px 15px 0px; here we can avoid the hexToRgba function, ain't this apporach good try this it works.

saini-himanshu commented 6 years ago

Also look at this it may be useful it works same -

  const Box = ({color1}) => {
  const rgb = [color1.substring(1,3), color1.substring(3,5), color1.substring(5,7)];
  const color2 = `rgb(${rgb.map(c => (parseInt(c, 16) * 0.8)).join()})`;
  return (
    <div className="box" style={{background: `linear-gradient(${color1}, ${color2})`}} />
  );
}
blenderskool commented 6 years ago

@saini-himanshu Yes, even that can be done, but hexToRgba() function would be needed in that case also since the opacity of the color needs to be changed. It can be easily done by just using 8-digits Hex color code but that isn't supported by all major browsers, hence some JS comes into play

saini-himanshu commented 6 years ago

ok, what about the linear-gradient method. it looks simplelinear-gradient(${color1}, ${color2}) just needs adjusting the value.

blenderskool commented 6 years ago

@saini-himanshu I was testing the color converter, it works fine for our case, and is a very simple implementation. Do note that you need to round the values after decimal multiplication since RGB does not have decimal numbers. I have made the changes :slightly_smiling_face:

saini-himanshu commented 6 years ago

👍