<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;
}
View Compiled
console.clear();

var Draggable = window.ReactDraggable;

class Content extends React.Component {
  render() {
    return(
      <div className="example-content">
        <h1><strong>This just in!</strong> Paperboy predicts precarious predic&shy;ament perfectly</h1>
        <div className="by">
          by Christopher Cripes Cyclestopper
        </div>
        
        <p>Wrapping lines on a web page is pretty complicated. There are a number of CSS properties that have a say in how it works. Vendor prefixes are involved. Alternate property names are involved. Values choices are involved. Cross-browser support is involved. Maybe someday it will get easier.</p>
        <p>Supercallafragaleisticexpialadoecsiousacally.</p>
        <p>https://fruitcakesandbakingingeneral.foodfoodiefooed.food</p>
        
        <p>This doesn't even deal with all the other related stuff like &lt;br>, &lt;wbr>, and &amp;shy;.</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">Drag Me</div>
            <h2>Line Wrapping Related Properties</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"));
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/16.2.0/umd/react.development.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.2.0/umd/react-dom.development.js
  3. https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/react-draggable.js