add CSS to emotion

This commit is contained in:
Ritesh Kumar committed 2017-10-03 20:40:02 +05:30
1 parent 3684eeffa8
commit a8a626275e
5 files changed
+1626 -447

No files matched your search

+21 -7
View File
@@ -1,4 +1,4 @@
import React, { PureComponent } from 'react'
import React, { PureComponent, Component } from 'react'
import isBrowser from 'is-in-browser'
import Link from 'next/link'
import Head from 'next/head'
@@ -38,6 +38,24 @@ function Logo () {
)
}
class CodeSponsor extends Component {
shouldComponentUpdate () {
return false
}
render () {
return (
<div>
<div id='code-sponsor-widget' />
<script
type='text/javascript'
src='https://app.codesponsor.io/scripts/mR5byaXd82L2zTVHo9eWvA?theme=dark&width=240&height=140&image=hide'
/>
</div>
)
}
}
function trackingScript () {
;(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r
@@ -46,7 +64,7 @@ function trackingScript () {
function () {
;(i[r].q = i[r].q || []).push(arguments)
}),
(i[r].l = 1 * new Date())
(i[r].l = 1 * new Date())
;(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0])
a.async = 1
a.src = g
@@ -330,11 +348,7 @@ export default class Layout extends PureComponent {
</div>
<div className='footer'>
<div id='code-sponsor-widget' />
<script
type='text/javascript'
src='https://app.codesponsor.io/scripts/mR5byaXd82L2zTVHo9eWvA?theme=dark&width=240&height=140&image=hide'
/>
<CodeSponsor />
Created by{' '}
<a
target='_blank'
+12 -11
View File
@@ -40,21 +40,22 @@
"codemirror": "^5.30.0",
"codemirror-graphql": "^0.6.11",
"copy-text-to-clipboard": "^1.0.3",
"css-in-js-generator": "^0.2.0",
"generate-schema": "^2.5.1",
"gofmt.js": "^0.0.2",
"is-in-browser": "^1.1.3",
"is-svg": "^2.1.0",
"json-schema-faker": "^0.5.0-rc11",
"json-schema-to-typescript": "^4.6.2",
"json-schema-to-typescript": "^4.6.4",
"lodash": "^4.17.4",
"next": "^3.2.2",
"next": "4.0.0-beta.2",
"nprogress": "^0.2.0",
"promise-worker": "^1.1.1",
"prop-types": "^15.5.10",
"prop-types": "^15.6.0",
"rc-collapse": "^1.7.6",
"react": "^15.6.1",
"react-codemirror2": "^2.0.0",
"react-dom": "^15.6.1",
"react": "^16.0.0",
"react-codemirror2": "^2.0.2",
"react-dom": "^16.0.0",
"react-fuzzy-picker": "^0.5.1",
"react-github-corner": "^1.0.0",
"stringify-object": "^3.2.1",
@@ -63,19 +64,19 @@
"transform-json-types": "^0.2.10",
"transform-svg-to-native": "^0.1.3",
"unfetch": "^3.0.0",
"xml-js": "^1.4.2"
"xml-js": "^1.5.0"
},
"devDependencies": {
"all-contributors-cli": "^4.4.0",
"all-contributors-cli": "^4.5.0",
"babili-webpack-plugin": "^0.1.2",
"css-loader": "^0.28.7",
"glob": "^7.1.2",
"husky": "^0.14.3",
"lint-staged": "^4.2.2",
"prettier-standard": "^6.0.0",
"lint-staged": "^4.2.3",
"prettier-standard": "^7.0.1",
"style-loader": "^0.18.2",
"sw-precache-webpack-plugin": "^0.11.4",
"webpack-bundle-analyzer": "^2.9.0",
"worker-loader": "^0.8.1"
"worker-loader": "^1.0.0"
}
}
+142
View File
@@ -0,0 +1,142 @@
import React, { PureComponent } from 'react'
import Layout from '../components/Layout'
import ConversionPanel from '../components/ConversionPanel'
import { convertCssForEmotion } from 'css-in-js-generator/lib/convertCssForEmotion'
const defaultText = `
*,
*::before,
*::after {
box-sizing: inherit;
}
@-ms-viewport {
width: device-width;
}
@media print {
.badge {
border: 1px solid #000;
}
}
select.form-control:not([size]):not([multiple]) {
height: calc(2.25rem + 2px);
}
.alert-dismissible .close {
position: relative;
top: -0.75rem;
right: -1.25rem;
padding: 0.75rem 1.25rem;
color: inherit;
}
.alert-link {
font-weight: bold;
}
.alert-primary {
color: #004085;
background-color: #cce5ff;
border-color: #b8daff;
}
.alert-primary hr {
border-top-color: #9fcdff;
}
.alert-primary .alert-link {
color: #002752;
}
.badge {
display: inline-block;
padding: 0.25em 0.4em;
font-size: 75%;
font-weight: bold;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: 0.25rem;
}
.badge-danger {
color: #fff;
background-color: #dc3545;
}
.badge-danger[href]:focus,
.badge-danger[href]:hover {
color: #fff;
text-decoration: none;
background-color: #bd2130;
}
.badge:empty {
display: none;
}
.blockquote-footer {
display: block;
font-size: 80%;
color: #868e96;
}
.blockquote-footer::before {
content: "\\\\2014 \\\\00A0";
}
.close {
float: right;
font-size: 1.5rem;
font-weight: bold;
line-height: 1;
color: #000;
text-shadow: 0 1px 0 #fff;
opacity: .5;
}
.display-1 {
font-size: 6rem;
font-weight: 300;
line-height: 1.1;
}
.display-2 {
font-size: 5.5rem;
font-weight: 300;
line-height: 1.1;
}
.form-control::placeholder {
color: #868e96;
opacity: 1;
}
`
export default class extends PureComponent {
state = {
isRn: false
}
getCode = code => {
let finalCode = ''
code.forEach((source, name) => {
source =
name === 'index.js' ? source.replace('css', 'injectGlobal') : source
finalCode += `
// ${name}
${source}`
})
return finalCode
}
getTransformedValue = code => {
return this.getCode(convertCssForEmotion(code))
}
render () {
return (
<Layout pathname={this.props.url.pathname}>
<ConversionPanel
leftTitle='CSS'
rightTitle='Emotion'
leftMode='css'
rightMode='typescript'
getTransformedValue={this.getTransformedValue}
name={'css_to_js'}
defaultText={defaultText}
extensions={null}
/>
</Layout>
)
}
}
+5
View File
@@ -56,6 +56,11 @@ export const categorizedRoutes = [
path: '/css-to-js',
desc:
'An online REPL for converting CSS to JS object. It also gives style optimized for React Native.'
},
{
label: 'CSS to Emotion',
path: '/css-to-emotion',
desc: 'An online REPL for converting CSS to Emotion compatible code.'
}
]
},
+1446 -429
View File
File diff suppressed because it is too large. Load diff