123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

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.

            
              <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
    <div id="container"></div>

            
          
!
            
              const words = [
    'In my dual profession as an educator and health care provider, I have worked with numerous children infected with the virus that causes AIDS. ',
    'The relationships that I have had with these special kids have been gifts in my life. They have taught me so many things, but I have especially learned that',
    'Tyler was born infected with HIV: his mother was also infected. From the very beginning of his life, he was dependent on medications to enable him to survive. When he was five',
    'he had a tube surgically inserted in a vein in his chest. This tube was connected to a pump, which he carried in a small backpack on his back. ',
    ' continuously supplied through this tube to his bloodstream. At times, he also needed supplemented oxygen to support his breathing.',
    'Tyler wasn’t willing to give up one single moment of his childhood to this deadly disease. It was not unusual to find him playing and racing around his backyard,',
    'wearing and dragging his tank of oxygen behind him in his little wagon. All of us who knew Tyler marveled at his pure joy in being alive and the energy it gave him.',
    'That way, when she peered through the window to check on him playing in the yard, she could quickly spot him.',
    'This dreaded disease eventually wore down even the likes of a little dynamo like Tyler. He grew quite ill and, unfortunately',
    ' When it became apparent that he wasn’t going to survive, Tyler’s mom talked to him about death. She comforted him by telling Tyler that she was dying too,'
];
const colors=[   
    'red','green','blue','white','purple','yellow','pink','silver','gray','orange'
];
const authors=[
    'red','green','blue','white','purple','yellow','pink','silver','gray','orange'
];



const actionCreator = () => {
    let aa = Math.floor(Math.random()*10);
    return {
        type:'UUU',
        word:words[aa],
        color:colors[aa],
        author:authors[aa]
    }
};
const defaultState = {
    color:'red',
    word:' When it became apparent that he wasn’t going to survive, Tyler’s mom talked to him about death. She comforted him by telling Tyler that she was dying too,',
    author:'red'
}
const reducer = (state = defaultState , action) => {
    switch (action.type) {
        case 'UUU':
            return {
                word:action.word,
                color:action.color,
                author:action.author
            }
        default:
            return state;
    }
}

// store
var store = Redux.createStore(reducer);

// component
class Web extends React.Component{
    constructor(props) {
        super(props);
        this.ddd=this.ddd.bind(this);
    }
    ddd(){
        setTimeout(() => { this.props.onClick(); },600)
    }

    render(){
        return(
            <div id='quote-box' className='container center'>
                <section style = {{backgroundColor: this.props.color,width:'100%',height:300}}>
                    <div style={{paddingTop:20}}>
                    <blockquote id='text'>“{this.props.word}”</blockquote>
                    <blockquote id='author'>“{this.props.author}”</blockquote>
                    </div>
                    <div>
                    <a id='tweet-quote' href='twitter.com/intent/tweet' style={{marginTop:120,marginRight:20}} className='waves-effect waves-light btn red'>Twitter</a>
                    <a style={{marginTop:120,marginRight:20}} className='btn waves-effect waves-light yellow'>b</a>
                    <a id='new-quote' style={{marginTop:120}} className='btn waves-effect waves-light green' onClick={this.ddd}>NEXT</a>
                    </div>
                </section>
                <b>by hutu zhu</b>
            </div>
        );
    }   
}

const mapStateToProps = (state = defaultState) => {
    const data = state;
    return {
        word: data.word,
        color: data.color,
        author: data.author
    }
}

const mapDispatchToProps = (dispatch) => {
    return {
        onClick: () => dispatch(actionCreator())
    }
}

const Contain = ReactRedux.connect(mapStateToProps,mapDispatchToProps)(Web);

var Provider = ReactRedux.Provider;
ReactDOM.render(
	<Provider store={store}>
	    <Contain />
	</Provider>,
    document.getElementById('container')
);
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console