.e{
background-image: url("data:image/svg+xml;utf8,<svg>....</svg>")
}
DIV:before{
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M19.414 27.414l10-10c0.781-0.781 0.781-2.047 0-2.828l-10-10c-0.781-0.781-2.047-0.781-2.828 0-0.781 0.781-0.781 2.047 0 2.828l6.586 6.586h-19.172c-1.105 0-2 0.895-2 2s0.895 2 2 2h19.172l-6.586 6.586c-0.39 0.39-0.586 0.902-0.586 1.414s0.195 1.024 0.586 1.414c0.781 0.781 2.047 0.781 2.828 0z" fill="#FFF" /></svg>');
}
const kebab = str => str.replace(/\b([A-Z][a-z]*)+\b/g, n => n.replace(/([A-Z])/g, '-$1').replace(/^-/, '').toLowerCase());
console.log(kebab('KebabCase noKebabCase No_Kebab_Case And FuckDonaldTrump!!')); // "kebab-case noKebabCase No_Kebab_Case and fuck-donald-trump!!"
async function getRoot(startPath) {
return new Promise(async (resolve, reject) => {
fs.access(`${startPath}/package.json`, fs.constants.F_OK, (err) => {
if (!err) {
resolve(startPath);
} else {
const arr = startPath.split('/');
arr.pop();
const newRoot = arr.join('/');
resolve(await (getRoot(newRoot)));
}
});
});
}
getRoot(process.env.PWD).then((data) => console.log(data));
class Child extends Component {
componentDidMount() {
this.props.callback();
}
render() {
return (
<div>Child</div>
);
}
}
class Parent extends Component {
onChildDidMount = () => {
console.log('Child component was mounted!');
// do something else
};
render() {
return(
<Wrapper>
<Child callback={this.onChildDidMount} />
</Wrapper>
);
}
}
const interval = 5 * 60 * 1000 // 5 минут, ага
const x = moment(Math.ceil(moment() / interval) * interval).format('HH:mm:ss')
import React, { Component } from 'react';
import Form from './Form';
import Button from './Button';
class App extends Component {
state = {
isChecked: false,
}
handleInputChange = event => {
this.setState({ isChecked: event.target.checked })
}
handleButtonClick = () => {
this.setState({ isChecked: !this.state.isChecked })
}
render() {
return (
<div className="App">
<Form
handleInputChange={this.handleInputChange}
isChecked={this.state.isChecked}
/>
<Button handleButtonClick={this.handleButtonClick}/>
</div>
);
}
}
export default App;
import React from 'react';
const Button = ({ handleButtonClick }) => (
<div>
<button onClick={handleButtonClick}>
clickme
</button>
</div>
)
export default Button;
import React from 'react';
const Form = ({ isChecked, handleInputChange }) => (
<input
type="checkbox"
checked={isChecked}
onChange={handleInputChange}
/>
)
export default Form;
<script type="text/javascript">
window.onload = function()
{
var width=0;
width = document.getElementById('block2').offsetWidth
document.body.style.width=width+'px';
};
</script>
@import "normalize";
includePaths: require('node-normalize-scss').includePaths
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
gulp.src('path/to/input.scss')
.pipe(sass({
// includePaths: require('node-normalize-scss').with('other/path', 'another/path')
// - or -
includePaths: require('node-normalize-scss').includePaths
}))
.pipe(gulp.dest('path/to/output.css'));
});