Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add placeholders #337

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ coverage
.nyc_output
/dist
/stats
/components
/components
/.prettierrc.json
rishichawda marked this conversation as resolved.
Show resolved Hide resolved
/yarn.lock
11 changes: 8 additions & 3 deletions lib/button/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
Expand Down Expand Up @@ -36,7 +38,7 @@ class Button extends Component {
[theme[`${type}Bordered`]]: bordered,
[theme[`${type}Borderless`]]: borderless,
[theme.iconButton]: iconButton,
},
}
);

let Icon;
Expand All @@ -52,7 +54,9 @@ class Button extends Component {
const rootProps = {
...others,
href: !href ? undefined : href,
className: classnames(theme.buttonWrapper, { [theme.iconButtonWrapper]: iconButton }),
className: classnames(theme.buttonWrapper, {
[theme.iconButtonWrapper]: iconButton,
}),
onMouseUp: this.handleMouseUp,
onMouseLeave: this.handleMouseLeave,
};
Expand All @@ -64,10 +68,11 @@ class Button extends Component {
className: classes,
disabled,
};

return (
<Element {...rootProps}>
<button type="button" {...buttonProps}>
{ icon !== null && <Icon /> }
{icon !== null && <Icon />}
{children}
</button>
</Element>
Expand Down
2 changes: 2 additions & 0 deletions lib/card/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */

import React from 'react';
import PropTypes from 'prop-types';
import { themr } from 'react-css-themr';
Expand Down
16 changes: 14 additions & 2 deletions lib/globals/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ $input-active-item: rgba(71, 233, 243, 0.2);
$input-bottom-border: #6c757d;
$primary-input-active-border: #47e9f3;
$secondary-input-active-border: #d8d8d8;
$dropdown-menu-shadow: 1px 1px 1px 2px rgba(233, 226, 226, 0.5), 0 1px 1px 0 rgba(194, 194, 194, 0.5);

$dropdown-menu-shadow: 1px 1px 1px 2px rgba(233, 226, 226, 0.5),
0 1px 1px 0 rgba(194, 194, 194, 0.5);

$orange-yellow: #ffa500;
$bright-cyan: #47e9f3;
$very-light-pink: #d8d8d8;
Expand Down Expand Up @@ -55,3 +56,14 @@ $dark-hot-pink-20: rgba(225, 0, 80, 0.2);
$orange-yellow-20: rgba(255, 165, 0, 0.2);
$battleship-grey-20: rgba(108, 117, 125, 0.2);
$dark-hot-pink-50: rgba(225, 0, 80, 0.5);

$shimmer-color-light: #f6f7f8;
$shimmer-color-dark: #edeef1;

// *********** BOX SHADOWS ****************
rishichawda marked this conversation as resolved.
Show resolved Hide resolved

$shadow-light: 0 2px 4px 0 rgba(0, 1, 38, 0.4);

// *********** BORDER RADIUS **************

$border-radius-medium: 6px;
98 changes: 66 additions & 32 deletions lib/globals/animations.module.scss
Original file line number Diff line number Diff line change
@@ -1,41 +1,75 @@
@mixin inputFocus() {
-o-animation-name: animateFocus;
-moz-animation-name: animateFocus;
-webkit-animation-name: animateFocus;
animation-name: animateFocus;
@keyframes animateFocus {
0% {
width: 0%;
}
100% {
width: 100%;
}
-o-animation-name: animateFocus;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this was due to prettier. Can you try removing prettier and lint files with eslint and see if it reverts these changes?

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

-moz-animation-name: animateFocus;
-webkit-animation-name: animateFocus;
animation-name: animateFocus;
@keyframes animateFocus {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
}

@mixin zoomIn() {
-o-animation-name: animateZoom;
-moz-animation-name: animateZoom;
-webkit-animation-name: animateZoom;
animation-name: animateZoom;
@keyframes animateZoom {
0% {
transform: scale(0.1);
}
100% {
transform: scale(1);
}
-o-animation-name: animateZoom;
-moz-animation-name: animateZoom;
-webkit-animation-name: animateZoom;
animation-name: animateZoom;
@keyframes animateZoom {
0% {
transform: scale(0.1);
}
100% {
transform: scale(1);
}
}
}

@mixin sectionEntry($duration) {
visibility: hidden;
opacity: 0;
transform: translate(0, 10px) perspective(200px) rotateX(-2deg);
&.enabled {
visibility: visible;
opacity: 1;
transition: visibility $duration, opacity $duration, transform $duration;
transform: translate(0, 0);
}
}
visibility: hidden;
opacity: 0;
transform: translate(0, 10px) perspective(200px) rotateX(-2deg);
&.enabled {
visibility: visible;
opacity: 1;
transition: visibility $duration, opacity $duration, transform $duration;
transform: translate(0, 0);
}
}

@mixin shimmer($duration: 2s) {
animation-duration: $duration;
animation-fill-mode: forwards;
animation-iteration-count: infinite;
animation-name: placeholderShimmer;
animation-timing-function: linear;

-webkit-animation-duration: 1s;
-webkit-animation-fill-mode: forwards;
-webkit-animation-iteration-count: infinite;
-webkit-animation-name: placeholderShimmer;
-webkit-animation-timing-function: linear;

@keyframes placeholderShimmer {
0% {
background-position: -468px 0;
}

100% {
background-position: 468px 0;
}
}

@-webkit-keyframes placeholderShimmer {
0% {
background-position: -468px 0;
}

100% {
background-position: 468px 0;
}
}
}
7 changes: 7 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ export { default as Carousel } from './carousel';
export { default as ProgressBar } from './progressbar';
export { default as Table } from './table';
export { default as Pagination } from './pagination';
export {
BoxPlaceholder,
LinePlaceholder,
ParagraphPlaceHolder,
CardPlaceholder,
ImageCard,
} from './placeholders';
6 changes: 4 additions & 2 deletions lib/navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ class Navbar extends React.Component {
{leftIcon && (
<div className={theme.leftIcon} onClick={onLeftIconClick}>
{React.isValidElement(leftIcon) ? leftIcon : <img src={leftIcon} alt="navbar-left-logo" />}
</div>)
</div>
)
}
<div className={theme.navbarContent}>
{this.renderLeftContent()}
Expand All @@ -152,7 +153,8 @@ class Navbar extends React.Component {
{rightIcon && (
<div className={theme.rightIcon} onClick={onRightIconClick}>
{React.isValidElement(rightIcon) ? rightIcon : <img src={rightIcon} alt="navbar-right-logo" />}
</div>)
</div>
)
}
</div>
<div className={classnames(theme.clearfix, 'clearfix')} />
Expand Down
29 changes: 29 additions & 0 deletions lib/placeholders/box/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { themr } from 'react-css-themr';

import '../../globals/fonts.scss';
import defaultTheme from './theme.module.scss';

const BoxPlaceholder = ({ theme, shape }) => {
const classes = classnames(theme.styles, theme.boxStyles, theme[shape]);

const boxPlaceholderProps = {
className: classes,
};

return <div {...boxPlaceholderProps} />;
};

BoxPlaceholder.propTypes = {
theme: PropTypes.shape({}),
shape: PropTypes.oneOf(['default', 'circle']),
};

BoxPlaceholder.defaultProps = {
theme: {},
shape: 'default',
};

export default themr('BPLACEHOLDER', defaultTheme)(BoxPlaceholder);
31 changes: 31 additions & 0 deletions lib/placeholders/box/readMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## Navbar
KRRISH96 marked this conversation as resolved.
Show resolved Hide resolved

The box placeholder component.

### Properties

| Name | Type | Default | Description |
| :------- | :------- | :-------- | :----------------------------------- |
| `square` | `circle` | &nbsp; | Shapes of the box default is circle. |
rishichawda marked this conversation as resolved.
Show resolved Hide resolved
| `shape` | `String` | `default` | Prop to set the shape of box. |

### Theme

| Name | Description |
| :---------- | :---------------------------------------- |
| `boxStyles` | Class used for the style the box element. |

### Usage

```

const Demo = ({theme, shape}) => {
const classes = classnames(theme.styles, theme.boxStyles, theme[shape]);

const boxPlaceholderProps = {
className: classes,
};

return <div {...boxPlaceholderProps} />;
}
KRRISH96 marked this conversation as resolved.
Show resolved Hide resolved
```
32 changes: 32 additions & 0 deletions lib/placeholders/box/tests/accessibility.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { mount } from 'enzyme';
import { expect, assert } from 'chai';

import BoxPlaceholder from '..';

/* eslint-disable no-undef */
describe('BoxPlaceholder accessibility tests', () => {
let wrappedComponent;
let expectedValue;
let actualValue;

beforeEach(() => {
wrappedComponent = mount(<BoxPlaceholder shape="circle" />);
});

afterEach(() => {
wrappedComponent.unmount();
});

it('allows us to set props', () => {
expect(wrappedComponent.props().shape).to.equal('circle');
wrappedComponent.setProps({ shape: 'default' });
expect(wrappedComponent.props().shape).to.equal('default');
});

it('should accept `Shape` prop', () => {
expectedValue = 'circle';
actualValue = () => wrappedComponent.prop('shape');
assert.strictEqual(actualValue(), expectedValue);
});
});
28 changes: 28 additions & 0 deletions lib/placeholders/box/tests/render.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import { mount } from 'enzyme';
import { expect } from 'chai';

import BoxPlaceHolder from '..';

/* eslint-disable no-undef */
describe('Box placeholder render test', () => {
let wrappedComponent;
const expectedValue = 1;
const actualValue = element => wrappedComponent.find(element).length;

beforeEach(() => {
wrappedComponent = mount(<BoxPlaceHolder />);
});

afterEach(() => {
wrappedComponent.unmount();
});

it('Should render the BoxPlaceholder component', () => {
expect(actualValue('div')).equal(expectedValue);
});

it('Should render a `BoxPlaceholder` with defalult `shape`', () => {
expect(wrappedComponent.props().shape).to.equal('default');
});
});
29 changes: 29 additions & 0 deletions lib/placeholders/box/theme.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@import '../../globals/theme';
@import '../../globals/animations.module.scss';

:local(.styles) {
background: $shimmer-color-light;
background-image: linear-gradient(
to right,
$shimmer-color-light 0%,
$shimmer-color-dark 20%,
$shimmer-color-light 40%,
$shimmer-color-light 100%
);
background-repeat: no-repeat;
// **** change here for height ***
// background-size: 800px 80px;
display: inline-block;
position: relative;

@include shimmer();
}

:local(.boxStyles) {
width: 80px;
height: 80px;
}

:local(.circle) {
border-radius: 100px;
}
Loading