Permalink
Browse files

Initial Commit

  • Loading branch information...
nem035 committed Dec 31, 2017
0 parents commit e649137456cc9573c247a0be7d8cb1273c80002d
@@ -0,0 +1,3 @@
{
"presets": ["./.babelrc.js"]
}
@@ -0,0 +1,14 @@
{
"parser": "babel-eslint",
"extends": ["airbnb", "prettier"],
"plugins": ["prettier"],
"rules": {
"react/jsx-filename-extension": 0,
"no-use-before-define": 0,
"no-param-reassign": 0
},
"env": {
"browser": true,
"node": true
}
}
@@ -0,0 +1,4 @@
node_modules
es/*
dist/*
package-lock.json
117 README.md
@@ -0,0 +1,117 @@
<p align="center">
<a href="https://www.npmjs.org/package/react-gridit">
<img src="https://github.com/nem035/react-gridit/logo.png" alt="react-gridit">
</a>
</p>
# [react-gridit](https://www.npmjs.org/package/react-gridit)
Simple React grid using [CSS Grid](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout) and [styled-components](https://www.styled-components.com/)
## Examples
### Rows
```jsx
<GridRows minSize="20px">
<Block>1 fr</Block>
<Block fr={2}>2 frs</Block>
<Block fr={3}>3 frs</Block>
<Block fr={4}>4 frs</Block>
<Block fr={5}>5 frs</Block>
</GridRows>
```
Output:
<img src="https://github.com/nem035/react-gridit/examples/rows.png" alt="react-gridit-rows">
### Columns
```jsx
<GridColumns minSize="50px">
<Block>1 fr</Block>
<Block fr={2}>2 frs</Block>
<Block fr={3}>3 frs</Block>
<Block fr={4}>4 frs</Block>
<Block fr={5}>5 frs</Block>
</GridColumns>
```
<img src="https://github.com/nem035/react-gridit/examples/columns.png" alt="react-gridit-columns">
### Nesting
```jsx
<GridRows minSize="20px">
<GridColumns>
<Block fr={1}>1 frs</Block>
<Block fr={3}>3 frs</Block>
</GridColumns>
<GridColumns>
<Block fr={5}>5 frs</Block>
</GridColumns>
<GridColumns>
<Block>1 fr</Block>
<Block fr={4}>4 frs</Block>
<Block fr={2}>2 frs</Block>
</GridColumns>
</GridRows>
```
<img src="https://github.com/nem035/react-gridit/examples/nesting.png" alt="react-gridit-nesting">
### Areas
```jsx
<GridArea
names={['header', 'sidebar', 'main1', 'main2', 'footer']}
area={`
"header header header header"
"sidebar . main1 main2"
"sidebar footer footer footer"
`}
>
<Block header>Header</Block>
<Block sidebar>Sidebar</Block>
<Block main1>Main1</Block>
<Block main2>Main2</Block>
<Block footer>Footer</Block>
</GridArea>
```
Output:
<img src="https://github.com/nem035/react-gridit/examples/area.png" alt="react-gridit-area">
### Responsive areas
```jsx
<GridArea
names={['header', 'sidebar', 'main1', 'main2', 'footer']}
area={`
"a b"
"c d"
`}
query="(max-width: 599px)"
fallbackArea={`"a b c d"`}
>
<Block a>A</Block>
<Block b>B</Block>
<Block c>C</Block>
<Block d>D</Block>
<Block footer>Footer</Block>
</GridArea>
```
Output (match):
<img src="https://github.com/nem035/react-gridit/examples/area-responsive-match.png" alt="react-gridit-area-responsive-match">
Output (no match):
<img src="https://github.com/nem035/react-gridit/examples/area-responsive-no-match.png" alt="react-gridit-area-responsive-no-match">
## License
MIT
Binary file not shown.
Binary file not shown.
BIN +19.7 KB examples/area.png
Binary file not shown.
BIN +13.1 KB examples/columns.png
Binary file not shown.
BIN +16.6 KB examples/nesting.png
Binary file not shown.
@@ -0,0 +1,21 @@
{
"name": "react-gridit-examples",
"version": "1.0.0",
"description": "",
"main": "examples.js",
"author": "Nemanja Stojanovic <me@nem035.com>",
"license": "MIT",
"dependencies": {
"react-dom": "^16.2.0",
"react-syntax-highlighter": "^6.1.1"
},
"devDependencies": {
"react-scripts": "1.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Binary file not shown.
@@ -0,0 +1,38 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
@@ -0,0 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
BIN +25.7 KB examples/rows.png
Binary file not shown.
@@ -0,0 +1,52 @@
// In production, we register a service worker to serve assets from local cache.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on the "N+1" visit to a page, since previously
// cached resources are updated in the background.
// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
// This link also includes instructions on opting out of this behavior.
export default function register() {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
navigator.serviceWorker
.register(swUrl)
.then(registration => {
// eslint-disable-next-line no-param-reassign
registration.onupdatefound = () => {
const installingWorker = registration.installing;
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the old content will have been purged and
// the fresh content will have been added to the cache.
// It's the perfect time to display a "New content is
// available; please refresh." message in your web app.
console.log('New content is available; please refresh.'); // eslint-disable-line no-console
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.'); // eslint-disable-line no-console
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
});
}
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
});
}
}
Oops, something went wrong.

0 comments on commit e649137

Please sign in to comment.