JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div id="app"></div>
html {
background: #ccc;
font-family: 'Droid Serif', serif;
font-size: 13px;
line-height: 1.3;
}
.content {
overflow: scroll;
resize: both;
padding: 1rem;
width: 260px;
height: 80vh;
background: #CB4338;
color: #fcf3bb;
}
img {
image-rendering: pixelated;
image-rendering: -moz-crisp-edges;
image-rendering: crisp-edges;
width: 100%;
float: left;
margin: 0 1rem 1rem 0;
}
.column-copy {
columns: auto 200px;
column-gap: 2rem;
padding: 1rem 0;
p {
margin: 0 0 1rem 0;
}
}
.controls {
width: 260px;
background: white;
padding: 1rem;
z-index: 1;
position: absolute;
bottom: 1rem;
right: 1rem;
}
.handle {
background: black;
color: white;
text-align: center;
}
h1 {
font-family: 'Playfair Display', serif;
strong {
font-weight: 900;
display: block;
text-transform: uppercase;
}
}
.by {
padding: 0.5rem;
border-top: 2px solid #ec6164;
border-bottom: 2px solid #ec6164;
}
h1 {
font-size: 1.8rem;
margin: 0 0 1rem 0;
strong {
font-size: 3rem;
}
}
label {
display: block;
}
body style {
display: block;
background: #333;
color: white;
white-space: pre;
padding: 10px;
font-family: monospace;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
}
.all-properties {
margin: 0 0 1rem 0;
font-family: monospace;
}
console.clear();
var Draggable = window.ReactDraggable;
class Content extends React.Component {
render() {
return(
<div className="example-content">
<h1><strong>Срочно в номер!</strong> Печатную полосу подстерегает пред­сказанная проблема</h1>
<div className="by">
Кристофер Кривоколессоу
</div>
<p>Переносы строк на странице довольно сложны. Есть ряд CSS-свойств, которые говорят, как переносить строки. Здесь замешаны браузерные префиксы, альтернативные названия свойств, выбор значений и кроссбраузерная поддержка. Возможно, однажды нам станет легче.</p>
<p>Никотинамидадениндинуклеотидфосфатполимераза.</p>
<p>https://fruitcakesandbakingingeneral.foodfoodiefooed.food</p>
<p>Это даже не касается других связаных с этим вещей: <br>, <wbr> и ­.</p>
<p>次の単語グレートブリテンおよび北アイルランド連合王国で本当に大きな言葉</p>
<div className="column-copy">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere quis corrupti minus doloribus sunt perspiciatis sequi quasi ratione voluptas magni, quos dignissimos sint, repellendus id voluptatum ducimus atque eius. Sequi doloribus iusto cupiditate. animi optio nulla nobis, totam quasi repellat ab! Quos excepturi at consequuntur quibusdam eius? Harum, iure!</p>
<img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/paperboy.png' alt='' />
<p>Possimus voluptatum eius ea doloremque iusto minima quasi tempore architecto voluptates, sit inventore libero, illum autem a sequi adipisci quod. Vero et cum nemo aspernatur aliquid temporibus iure reiciendis ratione dicta. Sit, dicta blanditiis quis doloribus beatae id reprehenderit atque aliquid laborum iusto illum praesentium tenetur labore! Incidunt minima nam consectetur officia assumenda dignissimos a vero beatae architecto magni nostrum ratione cum eos, officiis, quis cupiditate! Accusantium dolorem soluta exercitationem enim consequuntur, corrupti quidem voluptatibus odio veniam voluptatum possimus in?</p>
<p>Deleniti vitae voluptatibus incidunt labore vero distinctio odio praesentium dolorem hic quo. Aperiam corporis sint nostrum consequuntur esse. Quidem, quisquam tempora praesentium, ipsam rerum voluptatem ducimus est amet maxime eum minus nulla illo fugit doloribus impedit laudantium inventore distinctio tempore.</p>
</div>
</div>
);
}
}
class PropertyChoices extends React.Component {
constructor(props) {
super(props);
this.state = {
styles: {
'word-break: break-all;': false,
'word-break: break-word;': false,
'word-break: keep-all;': false,
'overflow-wrap: break-word;': false,
'hyphens: manual;': false,
'hyphens: auto;': false,
'line-break: loose;': false,
'line-break: strict;': false,
'line-break: anywhere;': false,
'text-wrap: balance;': false
}
};
}
componentDidUpdate() {
// React hates this.
// StyleFix.styleAttribute(
// document.querySelector("#style")
// );
}
toggleCheckbox(e) {
let property = e.target.parentElement.textContent;
this.setState({
styles: {
...this.state.styles,
[property]: !this.state.styles[property]
}
});
}
render() {
var _this = this;
let allStyles = ``;
Object.keys(this.state.styles).map(function(key) {
if (_this.state.styles[key]) {
if (key === 'hyphens: auto;') {
allStyles += ' -webkit-hyphens: auto;\n -moz-hyphens: auto;\n -ms-hyphens: auto;\n hyphens: auto;\n';
} else if (key === 'hyphens: manual;') {
allStyles += ' -webkit-hyphens: manual;\n -moz-hyphens: manual;\n -ms-hyphens: manual;\n hyphens: manual;\n';
} else if (key === 'overflow-wrap: break-word;') {
allStyles += ' word-wrap: break-word;\n overflow-wrap: break-word;\n';
} else {
allStyles += " " + key + "\n";
}
}
});
return(
<div>
<Draggable handle=".handle">
<form className="controls">
<div className="handle">Тащи меня</div>
<h2>Свойства, связанные с переносами строк</h2>
<div className="all-properties">
{Object.keys(this.state.styles).map(function(key, i) {
return(
<label key={i}>
<input type="checkbox"
checked={_this.state.styles[key]}
onChange={_this.toggleCheckbox.bind(_this)}
/>
{key}
</label>
);
})}
</div>
</form>
</Draggable>
<style id="style" contentEditable dangerouslySetInnerHTML={{
__html:
`body {
${allStyles}}`
}} />
</div>
);
}
}
ReactDOM.render(
<div className="grid">
<div className="choices">
<PropertyChoices />
</div>
<div className="content">
<Content />
</div>
</div>
, document.querySelector("#app"));
Also see: Tab Triggers