Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
hisk committed Dec 28, 2018
0 parents commit 4715002
Show file tree
Hide file tree
Showing 199 changed files with 35,719 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"plugins": [
"react"
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"env": {
"es6": true,
"browser": true,
"node": true,
"mocha": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"rules": {
}
}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git

# OS
.DS_Store

# Project dependencies
node_modules
yarn-error.log
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2018 DesignRevision <contact@designrevision.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<p align="center">
<img src="logo.jpg" width="230" />
</p>

<p align="center">
Shards React is a free, beautiful and modern React UI kit <br /> based on <a href="https://github.com/designrevision/shards-ui">Shards</a>.
</p>

<br />

<p align="center">
<a href="#">
<img src="https://img.shields.io/badge/License-MIT-brightgreen.svg" />
</a>
<a href="https://twitter.com/designrevision">
<img src="https://img.shields.io/twitter/follow/DesignRevision.svg?style=social&label=Follow" />
</a>
</p>

<br />

<p align="center">
<a href="https://designrevision.com/docs/shards-react/"><strong>Documentation & Demo</strong></a> •
<a href="https://designrevision.com/downloads/shards-react/"><strong>Official Page</strong></a>
</p>


### Getting Started

Getting started with Shards React is fairly simple. You can download Shards React via the official website, here on GitHub as a release package or by using a package manager such as Yarn or NPM.

* [Official Website](https://designrevision.com/downloads/shards-react)
* [Release Package](https://github.com/DesignRevision/shards-react/releases)

<br />

### Quick Start

You can install Shards React via Yarn or NPM.

```bash
# Yarn
yarn add shards-react

# NPM
npm i shards-react
```

<br />

### Module Bundlers

If you are using a module bundler such as [Webpack](https://webpack.js.org/) or [Rollup](https://rollupjs.org/), you can import components as follows:

```javascript
import { Alert } from "shards-react";

import "bootstrap/dist/css/bootstrap.min.css";
import "shards-ui/dist/css/shards.min.css"

// ...
```

<br />

### Built Using

* [Shards UI Kit](https://designrevision.com/downloads/shards/)
* [React Datepicker](https://reactdatepicker.com/)
* [React Popper](https://github.com/FezVrasta/react-popper)
* [noUiSlider by Léon Gersen (WTFPL License)](https://refreshless.com/nouislider/download/)

<br />

### Contributing

Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.

<br />

### Roadmap

[View the roadmap.](http://designrevision.com/docs/shards-react/roadmap)

<br />

### Changelog

[View notable changes.](CHANGELOG.md)
132 changes: 132 additions & 0 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
'use strict'

import path from 'path'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import babel from 'rollup-plugin-babel'
import minify from 'rollup-plugin-babel-minify'
import postcss from 'rollup-plugin-postcss'
import { name, version, dependencies, peerDependencies } from '../package.json'

const PATHS = {
INPUT: path.resolve(__dirname, '..', 'components', 'index.js'),
DIST: path.resolve(__dirname, '..', 'dist')
}

// Converts strings into camelCase
function camelize(str) {
return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function(match, index) {
if (+match === 0) {
return ''
}

return index == 0 ? match.toLowerCase() : match.toUpperCase()
})
}

const year = new Date().getFullYear()
const banner = `/*
* Shards React v${version} (https://designrevision.com/downloads/shards-react/)
* Based on: Bootstrap ${dependencies.bootstrap} (https://getbootstrap.com)
* Based on: Shards ${dependencies['shards-ui']} (https://designrevision.com/downloads/shards/)
* Copyright 2017-${year} DesignRevision (https://designrevision.com)
* Copyright 2017-${year} Catalin Vasile (http://catalin.me)
*/`

const globals = {
react: 'React',
'react-dom': 'ReactDOM',
'react-transition-group': 'ReactTransitionGroup',
'react-popper': 'ReactPopper',
'prop-types': 'PropTypes',
'lodash.pick': 'pick',
'lodash.omit': 'omit',
'lodash.isfunction': 'isFunction',
'react-datepicker': 'ReactDatePicker',
'shortid': 'shortid',
'lodash.tonumber': 'toNumber',
'nouislider': 'nouislider',
'classnames': 'classNames'
}

function createBaseConfig(callback) {
const baseConfig = {
input: PATHS.INPUT,
plugins: [
nodeResolve(),
commonjs({
include: 'node_modules/**' // Workaround for: https://github.com/rollup/rollup-plugin-commonjs/issues/247
}),
postcss(),
babel({
runtimeHelpers: true,
presets: [
"@babel/env",
"@babel/react"
]
})
],
external: Object.keys(Object.assign({}, peerDependencies, dependencies))
}

return callback(baseConfig)
}

const CommonJSConfig = createBaseConfig(function(config) {
return Object.assign({}, config, {
output: {
banner,
name: camelize(name),
sourcemap: true,
format: 'cjs',
file: path.resolve(PATHS.DIST, `${name}.common.js`)
}
})
})

const ESModulesConfig = createBaseConfig(function(config) {
return Object.assign({}, config, {
output: {
banner,
name: camelize(name),
sourcemap: true,
format: 'es',
file: path.resolve(PATHS.DIST, `${name}.es.js`)
}
})
})

const UMDConfig = createBaseConfig(function(config) {
return Object.assign({}, config, {
output: {
banner,
name: camelize(name),
sourcemap: true,
globals: globals,
format: 'umd',
file: path.resolve(PATHS.DIST, `${name}.umd.js`)
}
})
})

const MinifiedUMDConfig = createBaseConfig(function(config) {
config.plugins.push(minify({ comments: false }))

return Object.assign({}, config, {
output: {
banner,
name: camelize(name),
sourcemap: true,
globals: globals,
format: 'umd',
file: path.resolve(PATHS.DIST, `${name}.umd.min.js`)
}
})
})

module.exports = [
CommonJSConfig,
ESModulesConfig,
UMDConfig,
MinifiedUMDConfig
]
120 changes: 120 additions & 0 deletions components/alert/Alert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import React from "react";
import PropTypes from "prop-types";
import classNames from "classnames";

import Fade from "../fade";

/**
* The alert component can be used to display contextual user messages.
*/
const Alert = props => {
const {
className,
closeClassName,
closeAriaLabel,
tag: Tag,
theme,
open,
dismissible,
children,
transition,
fade,
...attrs
} = props;

const classes = classNames(
className,
"alert",
`alert-${theme}`,
dismissible && "alert-dismissible"
);

const closeClasses = classNames("close", closeClassName);

const alertTransition = {
...Fade.defaultProps,
...transition,
baseClass: fade ? transition.baseClass : "",
timeout: fade ? transition.timeout : 0
};

return (
<Fade
{...attrs}
{...alertTransition}
tag={Tag}
className={classes}
in={open}
role="alert"
>
{dismissible ? (
<button
type="button"
className={closeClasses}
aria-label={closeAriaLabel}
onClick={dismissible}
>
<span aria-hidden="true">&times;</span>
</button>
) : null}
{children}
</Fade>
);
};

Alert.propTypes = {
/**
* The children nodes.
*/
children: PropTypes.node,
/**
* The class name.
*/
className: PropTypes.string,
/**
* The close button's class name.
*/
closeClassName: PropTypes.string,
/**
* The close button's aria label.
*/
closeAriaLabel: PropTypes.string,
/**
* The theme color.
*/
theme: PropTypes.string,
/**
* Whether it should fade, or not.
*/
fade: PropTypes.bool,
/**
* Whether is open, or not.
*/
open: PropTypes.bool,
/**
* Whether is dismissible, or not.
*/
dismissible: PropTypes.func,
/**
* The transition config. See `Fade` component for more details.
*/
transition: PropTypes.shape(Fade.propTypes),
/**
* The component tag type.
*/
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
};

Alert.defaultProps = {
theme: "primary",
open: true,
tag: "div",
closeAriaLabel: "Close",
fade: true,
transition: {
...Fade.defaultProps,
unmountOnExit: true
}
};

export default Alert;
Loading

0 comments on commit 4715002

Please sign in to comment.