path
stringlengths
5
195
repo_name
stringlengths
5
79
content
stringlengths
25
1.01M
docs/src/ComponentsPage.js
apisandipas/react-bootstrap
/* eslint react/no-did-mount-set-state: 0 */ import React from 'react'; import getOffset from 'dom-helpers/query/offset'; import css from 'dom-helpers/style'; import Affix from '../../src/Affix'; import Nav from '../../src/Nav'; import SubNav from '../../src/SubNav'; import NavItem from '../../src/NavItem'; import NavMain from './NavMain'; import PageHeader from './PageHeader'; import PropTable from './PropTable'; import PageFooter from './PageFooter'; import ReactPlayground from './ReactPlayground'; import Samples from './Samples'; import Anchor from './Anchor'; const ComponentsPage = React.createClass({ getInitialState() { return { activeNavItemHref: null, navOffsetTop: null }; }, handleNavItemSelect(key, href) { this.setState({ activeNavItemHref: href }); window.location = href; }, componentDidMount() { let elem = React.findDOMNode(this.refs.sideNav); let sideNavOffsetTop = getOffset(elem).top; let sideNavMarginTop = parseInt(css(elem.firstChild, 'marginTop'), 10); let topNavHeight = React.findDOMNode(this.refs.topNav).offsetHeight; this.setState({ navOffsetTop: sideNavOffsetTop - topNavHeight - sideNavMarginTop, navOffsetBottom: React.findDOMNode(this.refs.footer).offsetHeight }); }, render() { return ( <div> <NavMain activePage='components' ref='topNav' /> <PageHeader title='Components' subTitle='' /> <div className='container bs-docs-container'> <div className='row'> <div className='col-md-9' role='main'> {/* Buttons */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='buttons'>Buttons</Anchor> <small>Button</small></h1> <h2><Anchor id='buttons-options'>Options</Anchor></h2> <p>Use any of the available button style types to quickly create a styled button. Just modify the <code>bsStyle</code> prop.</p> <ReactPlayground codeText={Samples.ButtonTypes} /> <div className='bs-callout bs-callout-warning'> <h4>Button spacing</h4> <p>Because React doesn't output newlines between elements, buttons on the same line are displayed flush against each other. To preserve the spacing between multiple inline buttons, wrap your button group in <code>{'<ButtonToolbar />'}</code>.</p> </div> <h2><Anchor id='buttons-sizes'>Sizes</Anchor></h2> <p>Fancy larger or smaller buttons? Add <code>bsSize="large"</code>, <code>bsSize="small"</code>, or <code>bsSize="xsmall"</code> for additional sizes.</p> <ReactPlayground codeText={Samples.ButtonSizes} /> <p>Create block level buttons—those that span the full width of a parent— by adding the <code>block</code> prop.</p> <ReactPlayground codeText={Samples.ButtonBlock} /> <h2><Anchor id='buttons-active'>Active state</Anchor></h2> <p>To set a buttons active state simply set the components <code>active</code> prop.</p> <ReactPlayground codeText={Samples.ButtonActive} /> <h2><Anchor id='buttons-disabled'>Disabled state</Anchor></h2> <p>Make buttons look unclickable by fading them back 50%. To do this add the <code>disabled</code> attribute to buttons.</p> <ReactPlayground codeText={Samples.ButtonDisabled} /> <div className='bs-callout bs-callout-warning'> <h4>Event handler functionality not impacted</h4> <p>This prop will only change the <code>{'<Button />'}</code>&#8217;s appearance, not its functionality. Use custom logic to disable the effect of the <code>onClick</code> handlers.</p> </div> <h2><Anchor id='buttons-tags'>Button tags</Anchor></h2> <p>The DOM element tag is choosen automatically for you based on the props you supply. Passing a <code>href</code> will result in the button using a <code>{'<a />'}</code> element otherwise a <code>{'<button />'}</code> element will be used.</p> <ReactPlayground codeText={Samples.ButtonTagTypes} /> <h2><Anchor id='buttons-loading'>Button loading state</Anchor></h2> <p>When activating an asynchronous action from a button it is a good UX pattern to give the user feedback as to the loading state, this can easily be done by updating your <code>{'<Button />'}</code>&#8217;s props from a state change like below.</p> <ReactPlayground codeText={Samples.ButtonLoading} /> <h3><Anchor id='buttons-props'>Props</Anchor></h3> <PropTable component='Button'/> </div> {/* Button Groups */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='btn-groups'>Button groups</Anchor> <small>ButtonGroup, ButtonToolbar</small></h1> <p className='lead'>Group a series of buttons together on a single line with the button group.</p> <h3><Anchor id='btn-groups-single'>Basic example</Anchor></h3> <p>Wrap a series of <code>{'<Button />'}</code>s in a <code>{'<ButtonGroup />'}</code>.</p> <ReactPlayground codeText={Samples.ButtonGroupBasic} /> <h3><Anchor id='btn-groups-toolbar'>Button toolbar</Anchor></h3> <p>Combine sets of <code>{'<ButtonGroup />'}</code>s into a <code>{'<ButtonToolbar />'}</code> for more complex components.</p> <ReactPlayground codeText={Samples.ButtonToolbarBasic} /> <h3><Anchor id='btn-groups-sizing'>Sizing</Anchor></h3> <p>Instead of applying button sizing props to every button in a group, just add <code>bsSize</code> prop to the <code>{'<ButtonGroup />'}</code>.</p> <ReactPlayground codeText={Samples.ButtonGroupSizes} /> <h3><Anchor id='btn-groups-nested'>Nesting</Anchor></h3> <p>You can place other button types within the <code>{'<ButtonGroup />'}</code> like <code>{'<DropdownButton />'}</code>s.</p> <ReactPlayground codeText={Samples.ButtonGroupNested} /> <h3><Anchor id='btn-groups-vertical'>Vertical variation</Anchor></h3> <p>Make a set of buttons appear vertically stacked rather than horizontally. <strong className='text-danger'>Split button dropdowns are not supported here.</strong></p> <p>Just add <code>vertical</code> to the <code>{'<ButtonGroup />'}</code>.</p> <ReactPlayground codeText={Samples.ButtonGroupVertical} /> <br /> <p>Moreover, you can have buttons be block level elements so they take the full width of their container, just add <code>block</code> to the <code>{'<ButtonGroup />'}</code>, in addition to the <code>vertical</code> you just added.</p> <ReactPlayground codeText={Samples.ButtonGroupBlock} /> <h3><Anchor id='btn-groups-justified'>Justified button groups</Anchor></h3> <p>Make a group of buttons stretch at equal sizes to span the entire width of its parent. Also works with button dropdowns within the button group.</p> <div className='bs-callout bs-callout-warning'> <h4>Style issues</h4> <p>There are some issues and workarounds required when using this property, please see <a href='http://getbootstrap.com/components/#btn-groups-justified'>bootstrap&#8217;s button group docs</a> for more specifics.</p> </div> <p>Just add <code>justified</code> to the <code>{'<ButtonGroup />'}</code>.</p> <ReactPlayground codeText={Samples.ButtonGroupJustified} /> <h3><Anchor id='btn-groups-props'>Props</Anchor></h3> <PropTable component='ButtonGroup'/> </div> <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='btn-dropdowns'>Button dropdowns</Anchor></h1> <p className='lead'>Use <code>{'<DropdownButton />'}</code> or <code>{'<SplitButton />'}</code> components to display a button with a dropdown menu.</p> <h3><Anchor id='btn-dropdowns-single'>Single button dropdowns</Anchor></h3> <p>Create a dropdown button with the <code>{'<DropdownButton />'}</code> component.</p> <ReactPlayground codeText={Samples.DropdownButtonBasic} /> <h3><Anchor id='btn-dropdowns-split'>Split button dropdowns</Anchor></h3> <p>Similarly, create split button dropdowns with the <code>{'<SplitButton />'}</code> component.</p> <ReactPlayground codeText={Samples.SplitButtonBasic} /> <h3><Anchor id='btn-dropdowns-sizing'>Sizing</Anchor></h3> <p>Button dropdowns work with buttons of all sizes.</p> <ReactPlayground codeText={Samples.DropdownButtonSizes} /> <h3><Anchor id='btn-dropdowns-nocaret'>No caret variation</Anchor></h3> <p>Remove the caret using the <code>noCaret</code> prop.</p> <ReactPlayground codeText={Samples.DropdownButtonNoCaret} /> <h3><Anchor id='btn-dropdowns-dropup'>Dropup variation</Anchor></h3> <p>Trigger dropdown menus that site above the button by adding the <code>dropup</code> prop.</p> <ReactPlayground codeText={Samples.SplitButtonDropup} /> <h3><Anchor id='btn-dropdowns-right'>Dropdown right variation</Anchor></h3> <p>Trigger dropdown menus that align to the right of the button using the <code>pullRight</code> prop.</p> <ReactPlayground codeText={Samples.SplitButtonRight} /> <h3><Anchor id='btn-dropdowns-custom'>Dropdown Customization</Anchor></h3> <p> If the default handling of the dropdown menu and toggle components aren't to your liking, you can customize them, by using the more basic <code>Dropdown</code> Component to explicitly specify the Toggle and Menu components </p> <div className='bs-callout bs-callout-info'> <h4>Additional Import Options</h4> <p> As a convenience Toggle and Menu components available as static properties on the Dropdown component. However, you can also import them directly, from the <code>/lib</code> directory like: <code>{"require('react-bootstrap/lib/DropdownToggle')"}</code>. </p> </div> <ReactPlayground codeText={Samples.DropdownButtonCustom} /> <h4>Custom Dropdown Components</h4> <p> For those that want to customize everything, you can forgo the included Toggle and Menu components, and create your own. In order to tell the Dropdown component what role your custom components play add a special prop <code>bsRole</code> to your menu or toggle components. The Dropdown expects at least one component with <code>bsRole='toggle'</code> and exactly one with <code>bsRole='menu'</code>. </p> <ReactPlayground codeText={Samples.DropdownButtonCustomMenu} /> <h3><Anchor id='btn-dropdowns-props'>Props</Anchor></h3> <h4><Anchor id='btn-dropdowns-props-dropdown-button'>DropdownButton</Anchor></h4> <PropTable component='DropdownButton'/> <h4><Anchor id='btn-dropdowns-props-split'>SplitButton</Anchor></h4> <PropTable component='SplitButton'/> <h4><Anchor id='btn-dropdowns-props-dropdown'>Dropdown</Anchor></h4> <PropTable component='Dropdown'/> </div> {/* Menu Item */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='menu-item'>Menu Item</Anchor> <small> MenuItem</small></h1> <p>This is a component used in other components (see <a href="buttons">Buttons</a>, <a href="#navbars">Navbars</a>).</p> <p>It supports the basic anchor properties <code>href</code>, <code>target</code>, <code>title</code>.</p> <p>It also supports different properties of the normal Bootstrap MenuItem. <ul> <li><code>header</code>: To add a header label to sections</li> <li><code>divider</code>: Adds an horizontal divider between sections</li> <li><code>disabled</code>: shows the item as disabled, and prevents the onclick</li> <li><code>eventKey</code>: passed to the callback</li> <li><code>onSelect</code>: a callback that is called when the user clicks the item.</li> </ul> <p>The callback is called with the following arguments: <code>eventKey</code>, <code>href</code> and <code>target</code></p> </p> <ReactPlayground codeText={Samples.MenuItem} /> <h3><Anchor id='menu-item-props'>Props</Anchor></h3> <PropTable component='MenuItem'/> </div> {/* Panels */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='panels'>Panels</Anchor> <small>Panel, PanelGroup, Accordion</small></h1> <h3><Anchor id='panels-basic'>Basic example</Anchor></h3> <p>By default, all the <code>&lt;Panel /&gt;</code> does is apply some basic border and padding to contain some content.</p> <p>You can pass on any additional properties you need, e.g. a custom <code>onClick</code> handler, as it is shown in the example code. They all will apply to the wrapper <code>div</code> element.</p> <ReactPlayground codeText={Samples.PanelBasic} /> <h3><Anchor id='panels-collapsible'>Collapsible Panel</Anchor></h3> <ReactPlayground codeText={Samples.PanelCollapsible} /> <h3><Anchor id='panels-heading'>Panel with heading</Anchor></h3> <p>Easily add a heading container to your panel with the <code>header</code> prop.</p> <ReactPlayground codeText={Samples.PanelWithHeading} /> <h3><Anchor id='panels-footer'>Panel with footer</Anchor></h3> <p>Pass buttons or secondary text in the <code>footer</code> prop. Note that panel footers do not inherit colors and borders when using contextual variations as they are not meant to be in the foreground.</p> <ReactPlayground codeText={Samples.PanelWithFooter} /> <h3><Anchor id='panels-contextual'>Contextual alternatives</Anchor></h3> <p>Like other components, easily make a panel more meaningful to a particular context by adding a <code>bsStyle</code> prop.</p> <ReactPlayground codeText={Samples.PanelContextual} /> <h3><Anchor id='panels-tables'>With tables and list groups</Anchor></h3> <p>Add the <code>fill</code> prop to <code>&lt;Table /&gt;</code> or <code>&lt;ListGroup /&gt;</code> elements to make them fill the panel.</p> <ReactPlayground codeText={Samples.PanelListGroupFill} /> <h3><Anchor id='panels-controlled'>Controlled PanelGroups</Anchor></h3> <p><code>PanelGroup</code>s can be controlled by a parent component. The <code>activeKey</code> prop dictates which panel is open.</p> <ReactPlayground codeText={Samples.PanelGroupControlled} /> <h3><Anchor id='panels-uncontrolled'>Uncontrolled PanelGroups</Anchor></h3> <p><code>PanelGroup</code>s can also be uncontrolled where they manage their own state. The <code>defaultActiveKey</code> prop dictates which panel is open when initially.</p> <ReactPlayground codeText={Samples.PanelGroupUncontrolled} /> <h3><Anchor id='panels-accordion'>Accordions</Anchor></h3> <p><code>&lt;Accordion /&gt;</code> aliases <code>&lt;PanelGroup accordion /&gt;</code>.</p> <ReactPlayground codeText={Samples.PanelGroupAccordion} /> <h3><Anchor id='panels-props'>Props</Anchor></h3> <h4><Anchor id='panels-props-accordion'>Panels, Accordion</Anchor></h4> <PropTable component='Panel'/> <h4><Anchor id='panels-props-group'>PanelGroup</Anchor></h4> <PropTable component='PanelGroup'/> </div> <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='modals'>Modals</Anchor> <small>Modal</small></h1> <h3><Anchor id='modals-static'>Static Markup</Anchor></h3> <p>A modal dialog component</p> <ReactPlayground codeText={Samples.ModalStatic} /> <h3><Anchor id='modals-live'>Basic example</Anchor></h3> <p></p> <p> A modal with header, body, and set of actions in the footer. Use <code>{'<Modal/>'}</code> in combination with other components to show or hide your Modal. The <code>{'<Modal/>'}</code> Component comes with a few convenient "sub components": <code>{'<Modal.Header/>'}</code>, <code>{'<Modal.Title/>'}</code>, <code>{'<Modal.Body/>'}</code>, and <code>{'<Modal.Footer/>'}</code>, which you can use to build the Modal content. </p> <ReactPlayground codeText={Samples.Modal} /> <div className='bs-callout bs-callout-info'> <h4>Additional Import Options</h4> <p> The Modal Header, Title, Body, and Footer components are available as static properties the <code>{'<Modal/>'}</code> component, but you can also, import them directly from the <code>/lib</code> directory like: <code>{"require('react-bootstrap/lib/ModalHeader')"}</code>. </p> </div> <h3><Anchor id='modals-contained'>Contained Modal</Anchor></h3> <p>You will need to add the following css to your project and ensure that your container has the <code>modal-container</code> class.</p> <pre> {React.DOM.code(null, '.modal-container {\n' + ' position: relative;\n' + '}\n' + '.modal-container .modal, .modal-container .modal-backdrop {\n' + ' position: absolute;\n' + '}\n' )} </pre> <ReactPlayground codeText={Samples.ModalContained} /> <h3><Anchor id='modal-default-sizing'>Sizing modals using standard Bootstrap props</Anchor></h3> <p>You can specify a bootstrap large or small modal by using the "bsSize" prop.</p> <ReactPlayground codeText={Samples.ModalDefaultSizing} /> <h3><Anchor id='modal-custom-sizing'>Sizing modals using custom CSS</Anchor></h3> <p>You can apply custom css to the modal dialog div using the "dialogClassName" prop. Example is using a custom css class with width set to 90%.</p> <ReactPlayground codeText={Samples.ModalCustomSizing} /> <h3><Anchor id='modals-props'>Props</Anchor></h3> <h4><Anchor id='modals-props-modal'>Modal</Anchor></h4> <PropTable component='Modal'/> <h4><Anchor id='modals-props-modal-header'>Modal.Header</Anchor></h4> <PropTable component='ModalHeader'/> <h4><Anchor id='modals-props-modal-title'>Modal.Title</Anchor></h4> <PropTable component='ModalTitle'/> <h4><Anchor id='modals-props-modal-body'>Modal.Body</Anchor></h4> <PropTable component='ModalBody'/> <h4><Anchor id='modals-props-modal-footer'>Modal.Footer</Anchor></h4> <PropTable component='ModalFooter'/> </div> {/* Tooltip */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='tooltips'>Tooltip</Anchor></h1> <p> Tooltip component for a more stylish alternative to that anchor tag <code>title</code> attribute. </p> <ReactPlayground codeText={Samples.TooltipBasic} exampleClassName='tooltip-static'/> <h4><Anchor id='tooltips-overlay-trigger'>With OverlayTrigger</Anchor></h4> <p>Attach and position tooltips with <code>OverlayTrigger</code>.</p> <ReactPlayground codeText={Samples.TooltipPositioned} /> <h4><Anchor id='tooltips-in-text'>In text copy</Anchor></h4> <p>Positioned tooltip in text copy.</p> <ReactPlayground codeText={Samples.TooltipInCopy} /> <h3><Anchor id='tooltips-props'>Props</Anchor></h3> <h4><Anchor id='overlays-trigger-props'>Overlay Trigger</Anchor></h4> <PropTable component='OverlayTrigger'/> <h4><Anchor id='tooltips-props-tooltip'>Tooltip</Anchor></h4> <PropTable component='Tooltip'/> </div> {/* Popover */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='popovers'>Popovers</Anchor></h1> <p> The Popover, offers a more robust alternative to the Tooltip for displaying overlays of content. </p> <ReactPlayground codeText={Samples.PopoverBasic}/> <h4><Anchor id='popovers-overlay-trigger'>With OverlayTrigger</Anchor></h4> <p>The Popover component, like the Tooltip can be used with an <code>OverlayTrigger</code> Component, and positioned around it.</p> <ReactPlayground codeText={Samples.PopoverPositioned} /> <h4><Anchor id='popovers-trigger-behaviors'>Trigger behaviors</Anchor></h4> <p>It's inadvisable to use <code>"hover"</code> or <code>"focus"</code> triggers for popovers, because they have poor accessibility from keyboard and on mobile devices.</p> <ReactPlayground codeText={Samples.PopoverTriggerBehaviors} /> <h4><Anchor id='popovers-in-container'>Popover component in container</Anchor></h4> <ReactPlayground codeText={Samples.PopoverContained} exampleClassName='bs-example-popover-contained' /> <h4><Anchor id='popovers-positioned-scrolling'>Positioned popover components in scrolling container</Anchor></h4> <ReactPlayground codeText={Samples.PopoverPositionedScrolling} exampleClassName='bs-example-popover-scroll' /> <h3><Anchor id='popover-props'>Props</Anchor></h3> <PropTable component='Popover'/> </div> {/* Overlay */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='overlays'>Overlay</Anchor></h1> <p> The <code>OverlayTrigger</code> component is great for most use cases, but as a higher level abstraction it can lack the flexibility needed to build more nuanced or custom behaviors into your Overlay components. For these cases it can be helpful to forgo the trigger and use the <code>Overlay</code> component directly. </p> <ReactPlayground codeText={Samples.Overlay}/> <h4><Anchor id='overlays-overlay'>Use Overlay instead of Tooltip and Popover</Anchor></h4> <p> You don't need to use the provided <code>Tooltip</code> or <code>Popover</code> components. Creating custom overlays is as easy as wrapping some markup in an <code>Overlay</code> component </p> <ReactPlayground codeText={Samples.OverlayCustom} /> <h3><Anchor id='overlays-props'>Props</Anchor></h3> <PropTable component='Overlay'/> </div> {/* Progress Bar */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='progress'>Progress bars</Anchor> <small>ProgressBar</small></h1> <p className='lead'>Provide up-to-date feedback on the progress of a workflow or action with simple yet flexible progress bars.</p> <h2><Anchor id='progress-basic'>Basic example</Anchor></h2> <p>Default progress bar.</p> <ReactPlayground codeText={Samples.ProgressBarBasic} /> <h2><Anchor id='progress-label'>With label</Anchor></h2> <p>Add a <code>label</code> prop to show a visible percentage. For low percentages, consider adding a min-width to ensure the label's text is fully visible.</p> <p>The following keys are interpolated with the current values: <code>%(min)s</code>, <code>%(max)s</code>, <code>%(now)s</code>, <code>%(percent)s</code>, <code>%(bsStyle)s</code></p> <ReactPlayground codeText={Samples.ProgressBarWithLabel} /> <h2><Anchor id='progress-screenreader-label'>Screenreader only label</Anchor></h2> <p>Add a <code>srOnly</code> prop to hide the label visually.</p> <ReactPlayground codeText={Samples.ProgressBarScreenreaderLabel} /> <h2><Anchor id='progress-contextual'>Contextual alternatives</Anchor></h2> <p>Progress bars use some of the same button and alert classes for consistent styles.</p> <ReactPlayground codeText={Samples.ProgressBarContextual} /> <h2><Anchor id='progress-striped'>Striped</Anchor></h2> <p>Uses a gradient to create a striped effect. Not available in IE8.</p> <ReactPlayground codeText={Samples.ProgressBarStriped} /> <h2><Anchor id='progress-animated'>Animated</Anchor></h2> <p>Add <code>active</code> prop to animate the stripes right to left. Not available in IE9 and below.</p> <ReactPlayground codeText={Samples.ProgressBarAnimated} /> <h2><Anchor id='progress-stacked'>Stacked</Anchor></h2> <p>Nest <code>&lt;ProgressBar /&gt;</code>s to stack them.</p> <ReactPlayground codeText={Samples.ProgressBarStacked} /> <h3><Anchor id='progress-props'>ProgressBar</Anchor></h3> <PropTable component='ProgressBar'/> </div> {/* Nav */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='navs'>Navs</Anchor> <small>Nav, NavItem</small></h1> <p>Navs come in two styles, <code>pills</code> and <code>tabs</code>. Disable a tab by adding <code>disabled</code>.</p> <ReactPlayground codeText={Samples.NavBasic} /> <h3><Anchor id='navs-dropdown'>Dropdown</Anchor></h3> <p>Add dropdowns using the <code>DropdownButton</code> component. Just make sure to set <code>navItem</code> property to true.</p> <ReactPlayground codeText={Samples.NavDropdown} /> <h3><Anchor id='navs-stacked'>Stacked</Anchor></h3> <p>They can also be <code>stacked</code> vertically.</p> <ReactPlayground codeText={Samples.NavStacked} /> <h3><Anchor id='navs-justified'>Justified</Anchor></h3> <p>They can be <code>justified</code> to take the full width of their parent.</p> <ReactPlayground codeText={Samples.NavJustified} /> <h3><Anchor id='navs-props'>Props</Anchor></h3> <h4><Anchor id='navs-props-nav'>Nav</Anchor></h4> <PropTable component='Nav'/> <h4><Anchor id='navs-props-navitem'>NavItem</Anchor></h4> <PropTable component='NavItem'/> </div> {/* Navbar */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='navbars'>Navbars</Anchor> <small>Navbar, Nav, NavItem</small></h1> <p>Navbars are by default accessible and will provide <code>role="navigation"</code>.</p> <p>They also supports all the different Bootstrap classes as properties. Just camelCase the css class and remove navbar from it. For example <code>navbar-fixed-top</code> becomes the property <code>fixedTop</code>. The different properties are <code>fixedTop</code>, <code>fixedBottom</code>, <code>staticTop</code>, <code>inverse</code>, <code>fluid</code>.</p> <p>You can drag elements to the right by specifying the <code>right</code> property on a nav group.</p> <h3><Anchor id='navbars-basic'>Navbar Basic Example</Anchor></h3> <ReactPlayground codeText={Samples.NavbarBasic} /> <h3><Anchor id='navbars-brand'>Navbar Brand Example</Anchor></h3> <p>You can specify a brand by passing in a string to <code>brand</code>, or you can pass in a renderable component.</p> <ReactPlayground codeText={Samples.NavbarBrand} /> <h3><Anchor id='navbars-mobile-friendly'>Mobile Friendly</Anchor></h3> <p>To have a mobile friendly Navbar, specify the property <code>toggleNavKey</code> on the Navbar with a value corresponding to an <code>eventKey</code> of one of his <code>Nav</code> children. This child will be the one collapsed.</p> <p>By setting the property {React.DOM.code(null, 'defaultNavExpanded')} the Navbar will start expanded by default.</p> <div className='bs-callout bs-callout-info'> <h4>Scrollbar overflow</h4> <p>The height of the collapsible is slightly smaller than the real height. To hide the scroll bar, add the following css to your style files.</p> <pre> {React.DOM.code(null, '.navbar-collapse {\n' + ' overflow: hidden;\n' + '}\n' )} </pre> </div> <ReactPlayground codeText={Samples.NavbarCollapsible} /> <h3><Anchor id='navbars-mobile-friendly-multiple'>Mobile Friendly (Multiple Nav Components)</Anchor></h3> <p>To have a mobile friendly Navbar that handles multiple <code>Nav</code> components use <code>CollapsibleNav</code>. The <code>toggleNavKey</code> must still be set, however, the corresponding <code>eventKey</code> must now be on the <code>CollapsibleNav</code> component.</p> <div className="bs-callout bs-callout-info"> <h4>Div collapse</h4> <p>The <code>navbar-collapse</code> div gets created as the collapsible element which follows the <a href="http://getbootstrap.com/components/#navbar-default">bootstrap</a> collapsible navbar documentation.</p> <pre>&lt;div class="collapse navbar-collapse"&gt;&lt;/div&gt;</pre> </div> <ReactPlayground codeText={Samples.CollapsibleNav} /> <h3><Anchor id='navbar-props'>Props</Anchor></h3> <PropTable component='Navbar'/> </div> {/* Tabbed Areas */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='tabs'>Togglable tabs</Anchor> <small>Tabs, Tab</small></h1> <p>Add quick, dynamic tab functionality to transition through panes of local content.</p> <h3><Anchor id='tabs-uncontrolled'>Uncontrolled</Anchor></h3> <p>Allow the component to control its own state.</p> <ReactPlayground codeText={Samples.TabsUncontrolled} exampleClassName='bs-example-tabs' /> <h3><Anchor id='tabs-controlled'>Controlled</Anchor></h3> <p>Pass down the active state on render via props.</p> <ReactPlayground codeText={Samples.TabsControlled} exampleClassName='bs-example-tabs' /> <h3><Anchor id='tabs-no-animation'>No animation</Anchor></h3> <p>Set the <code>animation</code> prop to <code>false</code></p> <ReactPlayground codeText={Samples.TabsNoAnimation} exampleClassName='bs-example-tabs' /> <h3><Anchor id='left-tabs'>Left tabs</Anchor></h3> <p>Set <code>position</code> to <code>'left'</code>. Optionally, <code>tabWidth</code> can be passed the number of columns for the tabs.</p> <ReactPlayground codeText={Samples.LeftTabs} exampleClassName='bs-example-tabs' /> <h3><Anchor id='tabs-props'>Props</Anchor></h3> <h4><Anchor id='tabs-props-area'>Tabs</Anchor></h4> <PropTable component='Tabs'/> <h4><Anchor id='tabs-props-pane'>Tab</Anchor></h4> <PropTable component='Tab'/> </div> {/* Pager */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='pager'>Pager</Anchor> <small>Pager, PageItem</small></h1> <p>Quick previous and next links.</p> <h3><Anchor id='pager-default'>Centers by default</Anchor></h3> <ReactPlayground codeText={Samples.PagerDefault} /> <h3><Anchor id='pager-aligned'>Aligned</Anchor></h3> <p>Set the <code>previous</code> or <code>next</code> prop to <code>true</code>, to align left or right.</p> <ReactPlayground codeText={Samples.PagerAligned} /> <h3><Anchor id='pager-disabled'>Disabled</Anchor></h3> <p>Set the <code>disabled</code> prop to <code>true</code> to disable the link.</p> <ReactPlayground codeText={Samples.PagerDisabled} /> <h3><Anchor id='pager-props'>Props</Anchor></h3> <h4><Anchor id='pager-props-pager'>Pager</Anchor></h4> <PropTable component='Pager'/> <h4><Anchor id='pager-props-pageitem'>PageItem</Anchor></h4> <PropTable component='PageItem'/> </div> {/* Pagination */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='pagination'>Pagination</Anchor> <small>Pagination</small></h1> <p>Provide pagination links for your site or app with the multi-page pagination component. Set <code>items</code> to the number of pages. <code>activePage</code> prop dictates which page is active</p> <ReactPlayground codeText={Samples.PaginationBasic} /> <h4><Anchor id='pagination-more'>More options</Anchor></h4> <p>such as <code>first</code>, <code>last</code>, <code>previous</code>, <code>next</code> and <code>ellipsis</code>.</p> <ReactPlayground codeText={Samples.PaginationAdvanced} /> <h3><Anchor id='pagination-props'>Props</Anchor></h3> <PropTable component='Pagination'/> </div> {/* Alerts */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='alerts'>Alert messages</Anchor> <small>Alert</small></h1> <p>Basic alert styles.</p> <ReactPlayground codeText={Samples.AlertBasic} /> <h4><Anchor id='alerts-closeable'>Closeable alerts</Anchor></h4> <p>just pass in a <code>onDismiss</code> function.</p> <ReactPlayground codeText={Samples.AlertDismissable} /> <h4><Anchor id='alerts-auto-closeable'>Auto closeable</Anchor></h4> <p>Auto close after a set time with <code>dismissAfter</code> prop.</p> <ReactPlayground codeText={Samples.AlertAutoDismissable} /> <h3><Anchor id='alert-props'>Props</Anchor></h3> <PropTable component='Alert'/> </div> {/* Carousels */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='carousels'>Carousels</Anchor> <small>Carousel, CarouselItem</small></h1> <h3><Anchor id='carousels-uncontrolled'>Uncontrolled</Anchor></h3> <p>Allow the component to control its own state.</p> <ReactPlayground codeText={Samples.CarouselUncontrolled} exampleClassName='bs-example-tabs' /> <h3><Anchor id='carousels-controlled'>Controlled</Anchor></h3> <p>Pass down the active state on render via props.</p> <ReactPlayground codeText={Samples.CarouselControlled} exampleClassName='bs-example-tabs' /> <h3><Anchor id='carousels-props'>Props</Anchor></h3> <h4><Anchor id='carousels-props-carousel'>Carousel</Anchor></h4> <PropTable component='Carousel'/> <h4><Anchor id='carousels-props-item'>CarouselItem</Anchor></h4> <PropTable component='CarouselItem'/> </div> {/* Grids */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='grids'>Grids</Anchor> <small>Grid, Row, Col</small></h1> <ReactPlayground codeText={Samples.GridBasic} exampleClassName='bs-example-tabs' /> <h3><Anchor id='grids-props'>Props</Anchor></h3> <h4><Anchor id='grids-props-grid'>Grid</Anchor></h4> <PropTable component='Grid'/> <h4><Anchor id='grids-props-row'>Row</Anchor></h4> <PropTable component='Row'/> <h4><Anchor id='grids-props-col'>Col</Anchor></h4> <PropTable component='Col'/> </div> {/* Thumbnail */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='thumbnail'>Thumbnail</Anchor></h1> <p>Thumbnails are designed to showcase linked images with minimal required markup. You can extend the grid component with thumbnails.</p> <h3><Anchor id='thumbnail-anchor'>Anchor Thumbnail</Anchor></h3> <p>Creates an anchor wrapping an image.</p> <ReactPlayground codeText={Samples.ThumbnailAnchor} /> <h3><Anchor id='thumbnail-divider'>Divider Thumbnail</Anchor></h3> <p>Creates a divider wrapping an image and other children elements.</p> <ReactPlayground codeText={Samples.ThumbnailDiv} /> <h3><Anchor id='thumbnail-props'>Props</Anchor></h3> <PropTable component='Thumbnail'/> </div> {/* ListGroup */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='listgroup'>List group</Anchor> <small>ListGroup, ListGroupItem</small></h1> <p>Quick previous and next links.</p> <h3><Anchor id='listgroup-default'>Centers by default</Anchor></h3> <ReactPlayground codeText={Samples.ListGroupDefault} /> <h3><Anchor id='listgroup-linked'>Linked</Anchor></h3> <p>Set the <code>href</code> or <code>onClick</code> prop on <code>ListGroupItem</code>, to create a linked or clickable element.</p> <ReactPlayground codeText={Samples.ListGroupLinked} /> <h3><Anchor id='listgroup-styling-state'>Styling by state</Anchor></h3> <p>Set the <code>active</code> or <code>disabled</code> prop to <code>true</code> to mark or disable the item.</p> <ReactPlayground codeText={Samples.ListGroupActive} /> <h3><Anchor id='listgroup-styling-color'>Styling by color</Anchor></h3> <p>Set the <code>bsStyle</code> prop to style the item</p> <ReactPlayground codeText={Samples.ListGroupStyle} /> <h3><Anchor id='listgroup-with-header'>With header</Anchor></h3> <p>Set the <code>header</code> prop to create a structured item, with a heading and a body area.</p> <ReactPlayground codeText={Samples.ListGroupHeader} /> <h3><Anchor id='listgroup-props'>Props</Anchor></h3> <h4><Anchor id='listgroup-props-group'>ListGroup</Anchor></h4> <PropTable component='ListGroup'/> <h4><Anchor id='listgroup-props-item'>ListGroupItem</Anchor></h4> <PropTable component='ListGroupItem'/> </div> {/* Labels */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='labels'>Labels</Anchor></h1> <p>Create a <code>{'<Label>label</Label>'}</code> to highlight information</p> <ReactPlayground codeText={Samples.Label} /> <h3><Anchor id='labels-variations'>Available variations</Anchor></h3> <p>Add any of the below mentioned modifier classes to change the appearance of a label.</p> <ReactPlayground codeText={Samples.LabelVariations} /> <h3><Anchor id='label-props'>Props</Anchor></h3> <PropTable component='Label'/> </div> {/* Badges */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='badges'>Badges</Anchor></h1> <p>Easily highlight new or unread items by adding a <code>{'<Badge>'}</code> to links, Bootstrap navs, and more.</p> <ReactPlayground codeText={Samples.Badge} /> <div className='bs-callout bs-callout-info'> <h4>Cross-browser compatibility</h4> <p>Unlike regular Bootstrap badges self collapse even in Internet Explorer 8.</p> </div> <h3><Anchor id='badges-props'>Props</Anchor></h3> <PropTable component='Badge'/> </div> {/* Jumbotron */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='jumbotron'>Jumbotron</Anchor></h1> <p>A lightweight, flexible component that can optionally extend the entire viewport to showcase key content on your site.</p> <ReactPlayground codeText={Samples.Jumbotron} /> <h3><Anchor id='jumbotron-props'>Props</Anchor></h3> <PropTable component='Jumbotron'/> </div> {/* Page Header */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='page-header'>Page Header</Anchor></h1> <p>A simple shell for an <code>h1</code> to appropriately space out and segment sections of content on a page. It can utilize the <code>h1</code>&#8217;s default <code>small</code> element, as well as most other components (with additional styles).</p> <ReactPlayground codeText={Samples.PageHeader} /> </div> {/* Wells */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='wells'>Wells</Anchor></h1> <p>Use the well as a simple effect on an element to give it an inset effect.</p> <ReactPlayground codeText={Samples.Well} /> <h2><Anchor id='wells-optional'>Optional classes</Anchor></h2> <p>Control padding and rounded corners with two optional modifier classes.</p> <ReactPlayground codeText={Samples.WellSizes} /> <h3><Anchor id='wells-props'>Props</Anchor></h3> <PropTable component='Well'/> </div> {/* Glyphicons */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='glyphicons'>Glyphicons</Anchor></h1> <p>Use them in buttons, button groups for a toolbar, navigation, or prepended form inputs.</p> <ReactPlayground codeText={Samples.Glyphicon} /> <h3><Anchor id='glyphicons-props'>Props</Anchor></h3> <PropTable component='Glyphicon'/> </div> {/* Tables */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='tables'>Tables</Anchor></h1> <p>Use the <code>striped</code>, <code>bordered</code>, <code>condensed</code> and <code>hover</code> props to customise the table.</p> <ReactPlayground codeText={Samples.TableBasic} /> <h2><Anchor id='table-responsive'>Responsive</Anchor></h2> <p>Add <code>responsive</code> prop to make them scroll horizontally up to small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.</p> <ReactPlayground codeText={Samples.TableResponsive} /> <h3><Anchor id='table-props'>Props</Anchor></h3> <PropTable component='Table'/> </div> {/* Input */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='input'>Input</Anchor></h1> <p>Renders an input in bootstrap wrappers. Supports label, help, text input add-ons, validation and use as wrapper. Use <code>getValue()</code> or <code>getChecked()</code> to get the current state. The helper method <code>getInputDOMNode()</code> returns the internal input element. If you don't want the <code>form-group</code> class applied apply the prop named <code>standalone</code>.</p> <ReactPlayground codeText={Samples.Input} /> <h3><Anchor id='input-types'>Types</Anchor></h3> <p>Supports <code>select</code>, <code>textarea</code>, as well as standard HTML input types. <code>getValue()</code> returns an array for multiple select.</p> <ReactPlayground codeText={Samples.InputTypes} /> <h3><Anchor id='input-static'>FormControls.Static</Anchor></h3> <p>Static text can be added to your form controls through the use of the <code>FormControls.Static</code> component.</p> <ReactPlayground codeText={Samples.StaticText} /> <h3><Anchor id='button-input-types'>Button Input Types</Anchor></h3> <p>Form buttons are encapsulated by <code>ButtonInput</code>. Pass in <code>type="reset"</code> or <code>type="submit"</code> to suit your needs. Styling is the same as <code>Button</code>.</p> <ReactPlayground codeText={Samples.ButtonInput} /> <h3><Anchor id='input-addons'>Add-ons</Anchor></h3> <p>Use <code>addonBefore</code> and <code>addonAfter</code> for normal addons, <code>buttonBefore</code> and <code>buttonAfter</code> for button addons. Exotic configurations may require some css on your side.</p> <ReactPlayground codeText={Samples.InputAddons} /> <h3><Anchor id='input-sizes'>Sizes</Anchor></h3> <p>Use <code>bsSize</code> to change the size of inputs. It also works with addons and most other options.</p> <ReactPlayground codeText={Samples.InputSizes} /> <h3><Anchor id='input-validation'>Validation</Anchor></h3> <p>Set <code>bsStyle</code> to one of <code>success</code>, <code>warning</code> or <code>error</code>. Add <code>hasFeedback</code> to show glyphicon. Glyphicon may need additional styling if there is an add-on or no label.</p> <ReactPlayground codeText={Samples.InputValidation} /> <h3><Anchor id='input-horizontal'>Horizontal forms</Anchor></h3> <p>Use <code>labelClassName</code> and <code>wrapperClassName</code> properties to add col classes manually. <code>checkbox</code> and <code>radio</code> types need special treatment because label wraps input.</p> <ReactPlayground codeText={Samples.InputHorizontal} /> <h3><Anchor id='input-wrapper'>Use as a wrapper</Anchor></h3> <p>If <code>type</code> is not set, child element(s) will be rendered instead of an input element. <code>getValue()</code> will not work when used this way.</p> <ReactPlayground codeText={Samples.InputWrapper} /> <h3><Anchor id='input-props'>Props</Anchor></h3> <PropTable component='InputBase'/> </div> {/* Utilities */} <div className='bs-docs-section'> <h1 className='page-header'><Anchor id='utilities'>Utilities</Anchor> <small>Portal, Position</small></h1> <h2><Anchor id='utilities-portal'>Portal</Anchor></h2> <p> A Component that renders its children into a new React "subtree" or <code>container</code>. The Portal component kind of like the React equivalent to jQuery's <code>.appendTo()</code>, which is helpful for components that need to be appended to a DOM node other than the component's direct parent. The Modal, and Overlay components use the Portal component internally. </p> <h3><Anchor id='utilities-portal-props'>Props</Anchor></h3> <PropTable component='Portal'/> <h2 id='utilities-position'><Anchor id='utilities-position'>Position</Anchor></h2> <p> A Component that absolutely positions its child to a <code>target</code> component or DOM node. Useful for creating custom popups or tooltips. Used by the Overlay Components. </p> <h3><Anchor id='utilities-position-props'>Props</Anchor></h3> <PropTable component='Position'/> <h2><Anchor id='utilities-transitions'>Transitions</Anchor></h2> <h3><Anchor id='utilities-collapse'>Collapse</Anchor></h3> <p>Add a collapse toggle animation to an element or component.</p> <ReactPlayground codeText={Samples.Collapse} /> <h4><Anchor id='utilities-collapse-props'>Props</Anchor></h4> <PropTable component='Collapse'/> <h3><Anchor id='utilities-fade'>Fade</Anchor></h3> <p>Add a fade animation to a child element or component.</p> <ReactPlayground codeText={Samples.Fade} /> <h4><Anchor id='utilities-fade-props'>Props</Anchor></h4> <PropTable component='Fade'/> </div> </div> <div className='col-md-3'> <Affix className='bs-docs-sidebar hidden-print' role='complementary' offsetTop={this.state.navOffsetTop} offsetBottom={this.state.navOffsetBottom}> <Nav className='bs-docs-sidenav' activeHref={this.state.activeNavItemHref} onSelect={this.handleNavItemSelect} ref='sideNav'> <SubNav href='#buttons' key={1} text='Buttons'> <NavItem href='#btn-groups' key={2}>Button groups</NavItem> <NavItem href='#btn-dropdowns' key={3}>Button dropdowns</NavItem> <NavItem href='#menu-item' key={25}>Menu Item</NavItem> </SubNav> <NavItem href='#panels' key={4}>Panels</NavItem> <NavItem href='#modals' key={5}>Modals</NavItem> <NavItem href='#tooltips' key={6}>Tooltips</NavItem> <NavItem href='#popovers' key={7}>Popovers</NavItem> <NavItem href='#overlays' key={27}>Overlays</NavItem> <NavItem href='#progress' key={8}>Progress bars</NavItem> <NavItem href='#navs' key={9}>Navs</NavItem> <NavItem href='#navbars' key={10}>Navbars</NavItem> <NavItem href='#tabs' key={11}>Tabs</NavItem> <NavItem href='#pager' key={12}>Pager</NavItem> <NavItem href='#pagination' key={13}>Pagination</NavItem> <NavItem href='#alerts' key={14}>Alerts</NavItem> <NavItem href='#carousels' key={15}>Carousels</NavItem> <NavItem href='#grids' key={16}>Grids</NavItem> <NavItem href='#thumbnail' key={17}>Thumbnail</NavItem> <NavItem href='#listgroup' key={18}>List group</NavItem> <NavItem href='#labels' key={19}>Labels</NavItem> <NavItem href='#badges' key={20}>Badges</NavItem> <NavItem href='#jumbotron' key={21}>Jumbotron</NavItem> <NavItem href='#page-header' key={22}>Page Header</NavItem> <NavItem href='#wells' key={23}>Wells</NavItem> <NavItem href='#glyphicons' key={24}>Glyphicons</NavItem> <NavItem href='#tables' key={25}>Tables</NavItem> <NavItem href='#input' key={26}>Input</NavItem> <NavItem href='#utilities' key={28}>Utilities</NavItem> </Nav> <a className='back-to-top' href='#top'> Back to top </a> </Affix> </div> </div> </div> <PageFooter ref='footer' /> </div> ); } }); export default ComponentsPage;
src/components/TooltipDefinition/TooltipDefinition-story.js
joshblack/carbon-components-react
/** * Copyright IBM Corp. 2016, 2018 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import React from 'react'; import { storiesOf } from '@storybook/react'; import { withKnobs, select, text } from '@storybook/addon-knobs'; import TooltipDefinition from '../TooltipDefinition'; const directions = { 'Bottom (bottom)': 'bottom', 'Top (top)': 'top', }; const props = () => ({ direction: select('Tooltip direction (direction)', directions, 'bottom'), tooltipText: text( 'Tooltip content (tooltipText)', 'Brief description of the dotted, underlined word above.' ), }); storiesOf('TooltipDefinition', module) .addDecorator(withKnobs) .add( 'default', () => ( <div style={{ marginTop: '2rem' }}> <TooltipDefinition {...props()}>Definition Tooltip</TooltipDefinition> </div> ), { info: { text: ` Definition Tooltip `, }, } );
React_Router_tutorial/modules/About.js
luongthomas/React-Portfolio
import React from 'react'; export default React.createClass({ render() { return <div>About</div>; }, });
docs/src/app/components/pages/components/Dialog/ExampleDialogDatePicker.js
pradel/material-ui
import React from 'react'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; import DatePicker from 'material-ui/DatePicker'; /** * Dialogs can be nested. This example opens a Date Picker from within a Dialog. */ export default class DialogExampleDialogDatePicker extends React.Component { state = { open: false, }; handleOpen = () => { this.setState({open: true}); }; handleClose = () => { this.setState({open: false}); }; render() { const actions = [ <FlatButton label="Ok" primary={true} keyboardFocused={true} onTouchTap={this.handleClose} />, ]; return ( <div> <RaisedButton label="Dialog With Date Picker" onTouchTap={this.handleOpen} /> <Dialog title="Dialog With Date Picker" actions={actions} modal={false} open={this.state.open} onRequestClose={this.handleClose} > Open a Date Picker dialog from within a dialog. <DatePicker hintText="Date Picker" /> </Dialog> </div> ); } }
docs/src/components/browser-dev-panel.js
kwangkim/nuclear-js
import React from 'react' export default React.createClass({ render() { return <div className="browser-component--dev-panel"> {this.props.children} </div> } })
src/scenes/home/footer/footer.js
NestorSegura/operationcode_frontend
import React from 'react'; import { Link } from 'react-router-dom'; import ScrollUpButton from 'react-scroll-up-button'; import SocialMedia from 'shared/components/socialMedia/socialMedia'; import centerLogo from 'images/icons/Medal-Icon.svg'; import styles from './footer.css'; const Footer = () => ( <div className={styles.footer}> <div className={styles.content}> <div className={styles.outerFooterGroupSocial}> <div className={styles.email} > <a href="mailto:[email protected]">[email protected]</a> </div> <SocialMedia /> </div> <div className={styles.logo}> <img src={centerLogo} alt="Operation Code Logo" /> <p className={styles.copyright}> Copyright {`${(new Date()).getUTCFullYear()} `} <br className={styles.copyrightLineBreak} /> Operation Code™ </p> </div> <div className={styles.outerFooterGroupLinks}> <div className={styles.blockGroup} > <Link to="/about">About</Link> <Link to="/press">Press</Link> <Link to="/branding">Branding</Link> <Link to="/faq">FAQ</Link> <Link to="/team">Team</Link> </div> <div className={styles.blockGroup}> <a href="https://github.com/OperationCode/operationcode_frontend/issues/new" target="_blank" rel="noopener noreferrer">Report A Bug</a> <a href="https://smile.amazon.com/ch/47-4247572" target="_blank" rel="noopener noreferrer">Amazon Smile</a> <Link to="/contact">Contact</Link> <a href="https://www.iubenda.com/privacy-policy/8174861" target="_blank" rel="noopener noreferrer">Privacy</a> <Link to="/terms">Terms of Service</Link> </div> <ScrollUpButton /> </div> </div> </div> ); export default Footer;
dispatch/static/manager/src/js/vendor/dispatch-editor/embeds/PullQuoteEmbed.js
ubyssey/dispatch
import React from 'react' import { TextInput } from '../../../components/inputs' import * as Form from '../../../components/Form' function PullQuoteEmbedComponent(props) { return ( <div className='o-embed o-embed--quote'> <Form.Container> <Form.Input label='Content'> <TextInput fill={true} value={props.data.content} onChange={e => props.updateField('content', e.target.value)} /> </Form.Input> <Form.Input label='Source'> <TextInput fill={true} value={props.data.source || ''} onChange={e => props.updateField('source', e.target.value)} /> </Form.Input> </Form.Container> </div> ) } export default { type: 'quote', component: PullQuoteEmbedComponent, defaultData: { content: '', source: '' } }
app/javascript/mastodon/features/compose/components/upload_progress.js
hyuki0000/mastodon
import React from 'react'; import PropTypes from 'prop-types'; import Motion from 'react-motion/lib/Motion'; import spring from 'react-motion/lib/spring'; import { FormattedMessage } from 'react-intl'; export default class UploadProgress extends React.PureComponent { static propTypes = { active: PropTypes.bool, progress: PropTypes.number, }; render () { const { active, progress } = this.props; if (!active) { return null; } return ( <div className='upload-progress'> <div className='upload-progress__icon'> <i className='fa fa-upload' /> </div> <div className='upload-progress__message'> <FormattedMessage id='upload_progress.label' defaultMessage='Uploading...' /> <div className='upload-progress__backdrop'> <Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}> {({ width }) => <div className='upload-progress__tracker' style={{ width: `${width}%` }} /> } </Motion> </div> </div> </div> ); } }
containers/ViewButton/index.js
bmagic/acdh-client
import React from 'react' import { connect } from 'react-redux' import { createStructuredSelector } from 'reselect' import PropTypes from 'prop-types' import Head from 'next/head' import { addView, deleteView } from 'actions/user' import { makeEmail, makeViewList, makeLoading } from 'selectors/user' import stylesheet from './style.scss' class ViewButton extends React.Component { constructor (props) { super(props) this.handleAddView = this.handleAddView.bind(this) this.handleDeleteView = this.handleDeleteView.bind(this) } handleDeleteView () { this.props.onDeleteView(this.props.id) } handleAddView () { this.props.onAddView(this.props.id) } render () { if (this.props.loading || !this.props.email) return null const isViewed = this.props.viewList && this.props.viewList.includes(this.props.id) return ( <div className='view-button'> <Head> <style dangerouslySetInnerHTML={{ __html: stylesheet }} /> </Head> {isViewed && <i className='fa fa-eye' onClick={this.handleDeleteView} />} {!isViewed && <i className='fa fa-eye-slash' onClick={this.handleAddView} />} </div> ) } } ViewButton.propTypes = { email: PropTypes.string, viewList: PropTypes.array, id: PropTypes.string.isRequired, loading: PropTypes.bool, onAddView: PropTypes.func, onDeleteView: PropTypes.func } const mapStateToProps = createStructuredSelector({ email: makeEmail(), viewList: makeViewList(), loading: makeLoading() }) export function mapDispatchToProps (dispatch) { return { onAddView: (id) => { dispatch(addView(id)) }, onDeleteView: (id) => { dispatch(deleteView(id)) } } } export default connect(mapStateToProps, mapDispatchToProps)(ViewButton)
src/components/icons/MicrosoftIcon.js
InsideSalesOfficial/insidesales-components
import React from 'react'; const MicrosoftIcon = props => ( <svg {...props.size || { width: '24px', height: '24px' }} {...props} viewBox="0 0 49 49"> {props.title && <title>{props.title}</title>} <path d="M0,0 L23.7179487,0 C23.7165242,7.92857143 23.7179487,15.8571429 23.7165242,23.7857143 L0,23.7857143 L0,0 Z"></path> <path d="M26.1396011,0 L49.8575499,0 C49.8575499,7.92857143 49.8589744,15.8571429 49.8561254,23.7857143 C41.951567,23.7842857 34.045584,23.7857143 26.1410256,23.7857143 C26.1381766,15.8571429 26.1396011,7.92857143 26.1396011,0"></path> <path d="M0,26.2128571 C7.90598291,26.2157143 15.8119658,26.2114286 23.7179487,26.2157143 C23.7193732,34.1442857 23.7179487,42.0714286 23.7179487,50 L0,50 L0,26.2128571 Z"></path> <path d="M26.1410256,26.2157143 C34.045584,26.2128571 41.951567,26.2142857 49.8575499,26.2142857 L49.8575499,50 L26.1396011,50 C26.1410256,42.0714286 26.1381766,34.1428571 26.1410256,26.2157143"></path> </svg> ); export default MicrosoftIcon;
app/screens/articles/articles2.js
it-surya/hack-jeninvest
import React from 'react'; import { FlatList, Image, View, TouchableOpacity } from 'react-native'; import { RkText, RkCard, RkStyleSheet } from 'react-native-ui-kitten'; import {SocialBar} from '../../components'; import {data} from '../../data'; let moment = require('moment'); export class Articles2 extends React.Component { static navigationOptions = { title: 'JenInvest'.toUpperCase() }; constructor(props) { super(props); this.data = data.getArticles(); this.renderItem = this._renderItem.bind(this); this._navigate = this._navigate.bind(this); } _keyExtractor(post, index) { return post.id; } _navigate = (id) => { this.setState({ aaa : true }) return this.props.navigation.navigate('Article', {id}) } _renderItem(info) { return ( <TouchableOpacity delayPressIn={70} activeOpacity={0.8} onPress={() => this._navigate(info.item.id)}> <RkCard rkType='imgBlock' style={styles.card}> <Image rkCardImg source={info.item.photo}/> <View rkCardImgOverlay rkCardContent style={styles.overlay}> <RkText rkType='header4 inverseColor'>{info.item.header}</RkText> </View> </RkCard> </TouchableOpacity> ) } render() { return ( <FlatList data={this.data} renderItem={this.renderItem} keyExtractor={this._keyExtractor} style={styles.container}/> ) } } let styles = RkStyleSheet.create(theme => ({ container: { backgroundColor: theme.colors.screen.scroll, paddingVertical: 8, paddingHorizontal: 14 }, card: { marginVertical: 8, }, time: { marginTop: 5 } }));
src/components/Gallery/Gallery.js
undefinedist/sicario
import React from 'react' import PropTypes from 'prop-types' import {Carousel} from 'react-responsive-carousel' import styles from 'react-responsive-carousel/lib/styles/carousel.min.css' function Gallery({images}) { return ( <Carousel axis="horizontal" showArrows showStatus={false} showThumbs={false} infiniteLoop interval={3500} dynamicHeight> {images.map(image => ( <div> <img src={image} /> </div> ))} </Carousel> ) } Gallery.propTypes = { images: PropTypes.array, } Gallery.defaultProps = { images: [ 'http://lorempixel.com/400/300/', 'http://lorempixel.com/400/300/', 'http://lorempixel.com/400/300/', ], } export default Gallery
docs/app/Examples/elements/Input/Variations/InputExampleRightLabeledBasic.js
koenvg/Semantic-UI-React
import React from 'react' import { Input } from 'semantic-ui-react' const InputExampleRightLabeledBasic = () => ( <Input label={{ basic: true, content: 'kg' }} labelPosition='right' placeholder='Enter weight...' /> ) export default InputExampleRightLabeledBasic
src/svg-icons/toggle/check-box.js
owencm/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ToggleCheckBox = (props) => ( <SvgIcon {...props}> <path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/> </SvgIcon> ); ToggleCheckBox = pure(ToggleCheckBox); ToggleCheckBox.displayName = 'ToggleCheckBox'; ToggleCheckBox.muiName = 'SvgIcon'; export default ToggleCheckBox;
packages/react-error-overlay/src/containers/RuntimeError.js
mangomint/create-react-app
/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ /* @flow */ import React from 'react'; import Header from '../components/Header'; import StackTrace from './StackTrace'; import type { StackFrame } from '../utils/stack-frame'; import type { ErrorLocation } from '../utils/parseCompileError'; const wrapperStyle = { display: 'flex', flexDirection: 'column', }; export type ErrorRecord = {| error: Error, unhandledRejection: boolean, contextSize: number, stackFrames: StackFrame[], |}; type Props = {| errorRecord: ErrorRecord, editorHandler: (errorLoc: ErrorLocation) => void, |}; function RuntimeError({ errorRecord, editorHandler }: Props) { const { error, unhandledRejection, contextSize, stackFrames } = errorRecord; const errorName = unhandledRejection ? 'Unhandled Rejection (' + error.name + ')' : error.name; // Make header prettier const message = error.message; let headerText = message.match(/^\w*:/) || !errorName ? message : errorName + ': ' + message; headerText = headerText // TODO: maybe remove this prefix from fbjs? // It's just scaring people .replace(/^Invariant Violation:\s*/, '') // This is not helpful either: .replace(/^Warning:\s*/, '') // Break the actionable part to the next line. // AFAIK React 16+ should already do this. .replace(' Check the render method', '\n\nCheck the render method') .replace(' Check your code at', '\n\nCheck your code at'); return ( <div style={wrapperStyle}> <Header headerText={headerText} /> <StackTrace stackFrames={stackFrames} errorName={errorName} contextSize={contextSize} editorHandler={editorHandler} /> </div> ); } export default RuntimeError;
definitions/npm/styled-components_v2.x.x/flow_v0.42.x-/test_styled-components_native_v2.x.x.js
echenley/flow-typed
// @flow import nativeStyled, { ThemeProvider as NativeThemeProvider, withTheme as nativeWithTheme, keyframes as nativeKeyframes, } from 'styled-components/native' import React from 'react' import type { Theme as NativeTheme, Interpolation as NativeInterpolation, // Temporary ReactComponentFunctional as NativeReactComponentFunctional, ReactComponentClass as NativeReactComponentClass, ReactComponentStyled as NativeReactComponentStyled, ReactComponentStyledTaggedTemplateLiteral as NativeReactComponentStyledTaggedTemplateLiteral, ReactComponentUnion as NativeReactComponentUnion, ReactComponentIntersection as NativeReactComponentIntersection, } from 'styled-components' const NativeTitleTaggedTemplateLiteral: NativeReactComponentStyledTaggedTemplateLiteral<*> = nativeStyled.Text; const NativeTitleStyled: NativeReactComponentStyled<*> = nativeStyled.Text` font-size: 1.5em; `; const NativeTitleGeneric: NativeReactComponentIntersection<*> = nativeStyled.Text` font-size: 1.5em; `; const NativeTitleFunctional: NativeReactComponentFunctional<*> = nativeStyled.Text` font-size: 1.5em; `; const NativeTitleClass: NativeReactComponentClass<*> = nativeStyled.Text` font-size: 1.5em; `; declare var nativeNeedsReactComponentFunctional: NativeReactComponentFunctional<*> => void declare var nativeNeedsReactComponentClass: NativeReactComponentClass<*> => void nativeNeedsReactComponentFunctional(NativeTitleStyled) nativeNeedsReactComponentClass(NativeTitleStyled) const NativeExtendedTitle: NativeReactComponentIntersection<*> = nativeStyled(NativeTitleStyled)` font-size: 2em; `; const NativeWrapper: NativeReactComponentIntersection<*> = nativeStyled.View` padding: 4em; background: ${({theme}) => theme.background}; `; // ---- EXTEND ---- const NativeAttrs0ReactComponent: NativeReactComponentStyled<*> = nativeStyled.View.extend``; const NativeAttrs0ExtendReactComponent: NativeReactComponentIntersection<*> = NativeAttrs0ReactComponent.extend``; const NativeAttrs0SyledComponent: NativeReactComponentStyledTaggedTemplateLiteral<*> = nativeStyled.View; const NativeAttrs0ExtendStyledComponent: NativeReactComponentIntersection<*> = NativeAttrs0SyledComponent.extend``; // ---- ATTRIBUTES ---- const NativeAttrs1: NativeReactComponentStyledTaggedTemplateLiteral<*> = nativeStyled.View.attrs({ testProp: 'foo' }); // $ExpectError const NativeAttrs1Error: NativeReactComponentStyledTaggedTemplateLiteral<*> = nativeStyled.View.attrs({ testProp: 'foo' })``; declare var needsString: string => void nativeNeedsReactComponentFunctional(nativeStyled.View.attrs({})``) nativeNeedsReactComponentClass(nativeStyled.View.attrs({})``) // $ExpectError needsString(nativeStyled.View.attrs({})``) const NativeAttrs2: NativeReactComponentStyledTaggedTemplateLiteral<*> = nativeStyled.View .attrs({ testProp1: 'foo' }) .attrs({ testProp2: 'bar' }); const NativeAttrs3Styled: NativeReactComponentStyled<*> = nativeStyled.View.attrs({ testProp: 'foo' })` background-color: red; `; const NativeAttrs3Generic: NativeReactComponentIntersection<*> = nativeStyled.View.attrs({ testProp: 'foo' })` background-color: red; `; const NativeAttrs3Functional: NativeReactComponentFunctional<*> = nativeStyled.View.attrs({ testProp: 'foo' })` background-color: red; `; const NativeAttrs3Class: NativeReactComponentClass<*> = nativeStyled.View.attrs({ testProp: 'foo' })` background-color: red; `; const nativeTheme: NativeTheme = { background: "papayawhip" }; // ---- WithComponent ---- const NativeWithComponent1: NativeReactComponentStyled<*> = nativeStyled.View.withComponent('Text'); const NativeWithComponent2: NativeReactComponentStyled<*> = nativeStyled.View.withComponent(NativeWithComponent1); const NativeWithComponent3: NativeReactComponentStyled<*> = nativeStyled.View.withComponent(NativeAttrs3Class); // $ExpectError const NativeWithComponentError1: NativeReactComponentStyled<*> = nativeStyled.View.withComponent(0); // $ExpectError const NativeWithComponentError2: NativeReactComponentStyled<*> = nativeStyled.View.withComponent('NotHere'); // ---- WithTheme ---- const NativeComponent: NativeReactComponentFunctional<{ theme: NativeTheme }> = ({ theme }) => ( <NativeThemeProvider theme={theme}> <NativeWrapper> <NativeTitleStyled>Hello World, this is my first styled component!</NativeTitleStyled> </NativeWrapper> </NativeThemeProvider> ); const NativeComponentWithTheme: NativeReactComponentFunctional<{}> = nativeWithTheme(NativeComponent); const NativeComponent2: NativeReactComponentFunctional<{}> = () => ( <NativeThemeProvider theme={outerTheme => outerTheme}> <NativeWrapper> <NativeTitleStyled>Hello World, this is my first styled component!</NativeTitleStyled> </NativeWrapper> </NativeThemeProvider> ); const NativeOpacityKeyFrame: string = nativeKeyframes` 0% { opacity: 0; } 100% { opacity: 1; } `; // $ExpectError const NativeNoExistingElementWrapper = nativeStyled.nonexisting` padding: 4em; background: papayawhip; `; const nativeNum: 9 = 9 // $ExpectError const NativeNoExistingComponentWrapper = nativeStyled()` padding: 4em; background: papayawhip; `; // $ExpectError const NativeNumberWrapper = nativeStyled(nativeNum)` padding: 4em; background: papayawhip; `; // ---- COMPONENT CLASS TESTS ---- class NativeNeedsThemeReactClass extends React.Component { props: { foo: string, theme: NativeTheme } render() { return <div />; } } class NativeReactClass extends React.Component { props: { foo: string } render() { return <div />; } } const NativeStyledClass: NativeReactComponentClass<{ foo: string, theme: NativeTheme }> = nativeStyled(NativeNeedsThemeReactClass)` color: red; `; const NativeNeedsFoo1Class: NativeReactComponentClass<{ foo: string }, { theme: NativeTheme }> = nativeWithTheme(NativeNeedsThemeReactClass); // $ExpectError const NativeNeedsFoo0ClassError: NativeReactComponentClass<{ foo: string }> = nativeWithTheme(NativeReactClass); // $ExpectError const NativeNeedsFoo1ClassError: NativeReactComponentClass<{ foo: string }> = nativeWithTheme(NeedsFoo1Class); // $ExpectError const NativeNeedsFoo1ErrorClass: NativeReactComponentClass<{ foo: number }> = nativeWithTheme(NativeNeedsThemeReactClass); // $ExpectError const NativeNeedsFoo2ErrorClass: NativeReactComponentClass<{ foo: string }, { theme: string }> = nativeWithTheme(NativeNeedsThemeReactClass); // $ExpectError const NativeNeedsFoo3ErrorClass: NativeReactComponentClass<{ foo: string, theme: NativeTheme }> = nativeWithTheme(NativeNeedsFoo1Class); // $ExpectError const NativeNeedsFoo4ErrorClass: NativeReactComponentClass<{ foo: number }> = nativeWithTheme(NativeNeedsFoo1Class); // $ExpectError const NativeNeedsFoo5ErrorClass: NativeReactComponentClass<{ foo: string, theme: string }> = nativeWithTheme(NativeNeedsFoo1Class); // ---- INTERPOLATION TESTS ---- const nativeInterpolation: Array<NativeInterpolation> = nativeStyled.css` background-color: red; `; // $ExpectError const nativeInterpolationError: Array<NativeInterpolation | boolean> = nativeStyled.css` background-color: red; `; // ---- DEFAULT COMPONENT TESTS ---- const NativeDefaultComponent: NativeReactComponentIntersection<{}> = nativeStyled.View` background-color: red; `; // $ExpectError const NativeDefaultComponentError: {} => string = nativeStyled.View` background-color: red; `; // ---- FUNCTIONAL COMPONENT TESTS ---- declare var View: ({}) => React$Element<*> const NativeFunctionalComponent: NativeReactComponentFunctional<{ foo: string, theme: NativeTheme }> = props => <View />; const NativeNeedsFoo1: NativeReactComponentFunctional<{ foo: string, theme: NativeTheme }> = nativeStyled(NativeFunctionalComponent)` background-color: red; `; // $ExpectError const NativeNeedsFoo1Error: NativeReactComponentFunctional<{ foo: number }> = nativeStyled(NativeFunctionalComponent)` background-color: red; `; const NativeNeedsFoo2: NativeReactComponentFunctional<{ foo: string, theme: NativeTheme }> = nativeStyled(NativeNeedsFoo1)` background-color: red; `; // $ExpectError const NativeNeedsFoo2Error: NativeReactComponentFunctional<{ foo: number }> = nativeStyled(NativeNeedsFoo1)` background-color: red; `; // ---- FUNCTIONAL COMPONENT TESTS (nativeWithTheme)---- const NativeNeedsFoo1Functional: NativeReactComponentFunctional<{ foo: string }> = nativeWithTheme(NativeFunctionalComponent); const NativeNeedsFoo2Functional: NativeReactComponentFunctional<{ foo: string }> = nativeWithTheme(NativeNeedsFoo1Functional); // $ExpectError const NativeNeedsFoo1ErrorFunctional: NativeReactComponentFunctional<{ foo: number }> = nativeWithTheme(NativeFunctionalComponent); // $ExpectError const NativeNeedsFoo2ErrorFunctional: NativeReactComponentFunctional<{ foo: string }, { theme: string }> = nativeWithTheme(NativeFunctionalComponent); // $ExpectError const NativeNeedsFoo3ErrorFunctional: NativeReactComponentFunctional<{ foo: number, theme: NativeTheme }> = nativeWithTheme(NativeFunctionalComponent); // $ExpectError const NativeNeedsFoo4ErrorFunctional: NativeReactComponentFunctional<{ foo: number }> = nativeWithTheme(NativeNeedsFoo1Functional); // $ExpectError const NativeNeedsFoo5ErrorFunctional: NativeReactComponentFunctional<{ foo: string }, { theme: string }> = nativeWithTheme(NativeNeedsFoo1Functional); // $ExpectError const NativeNeedsFoo6ErrorFunctional: NativeReactComponentFunctional<{ foo: number }, { theme: NativeTheme }> = nativeWithTheme(NativeNeedsFoo1Functional);
src/ButtonGroup.js
xsistens/react-bootstrap
import React from 'react'; import classNames from 'classnames'; import BootstrapMixin from './BootstrapMixin'; import CustomPropTypes from './utils/CustomPropTypes'; const ButtonGroup = React.createClass({ mixins: [BootstrapMixin], propTypes: { vertical: React.PropTypes.bool, justified: React.PropTypes.bool, /** * Display block buttons, only useful when used with the "vertical" prop. * @type {bool} */ block: CustomPropTypes.all([ React.PropTypes.bool, function(props, propName, componentName) { if (props.block && !props.vertical) { return new Error('The block property requires the vertical property to be set to have any effect'); } } ]) }, getDefaultProps() { return { block: false, bsClass: 'button-group', justified: false, vertical: false }; }, render() { let classes = this.getBsClassSet(); classes['btn-group'] = !this.props.vertical; classes['btn-group-vertical'] = this.props.vertical; classes['btn-group-justified'] = this.props.justified; classes['btn-block'] = this.props.block; return ( <div {...this.props} className={classNames(this.props.className, classes)}> {this.props.children} </div> ); } }); export default ButtonGroup;
src/game-middleware/speechReducer.js
DelvarWorld/some-game
import { Kbd } from 'components'; import React from 'react'; import { ENTER, SPACE, } from 'helpers/KeyCodes'; const textExpandTime = 900; const textCloseTime = 500; const msPerLetter = 35; function generateText( text:string, index:number ) { return <span> { text.substr( 0, index, ) } { index >= text.length ? <span>&nbsp;<Kbd green>Enter</Kbd></span> : null } </span>; } export default function speechReducer( keysDown:Object, actions:Object, gameData:Object, oldState:Object, currentState:Object, next:Function ) { const { textQueue: oldTextQueue, textVisibleStartTime: oldTextVisibleStartTime, textIsVisible: oldTextIsVisible, activeTextStartTime: oldActiveTextStartTime, textCloseStartTime: oldTextCloseStartTime, textIsClosing: oldTextIsClosing, } = oldState; const { time, } = currentState; let newState = {}; let textVisibleStartTime = oldTextVisibleStartTime; let textIsVisible = oldTextIsVisible; let activeTextStartTime = oldActiveTextStartTime; let textQueue = currentState.textQueue || oldTextQueue || []; let textCloseStartTime = oldTextCloseStartTime; let textIsClosing = oldTextIsClosing; // Is there text to display? if( !textCloseStartTime && textQueue.length ) { textIsVisible = true; const currentText = textQueue[ 0 ]; // Is the text box closed? if( !textVisibleStartTime ) { textVisibleStartTime = time; } // If the text box isn't fully open yet, finish animating it const timeSinceTextVisible = time - textVisibleStartTime; newState.textOpenPercent = Math.min( timeSinceTextVisible / textExpandTime, 1 ); // When the box finishes opening, note the current time if( !activeTextStartTime && newState.textOpenPercent === 1 ) { newState.textOpenPercent = 1; activeTextStartTime = time; } // Otherwise tween the text display based on the time elapsed if( activeTextStartTime ) { const currentTextIndex = Math.min( Math.round( ( ( time - activeTextStartTime ) / msPerLetter ) ), currentText.length ); newState.currentTextPercent = currentTextIndex / currentText.length; newState.visibleText = generateText( currentText, currentTextIndex ); const isFullyShown = currentTextIndex >= currentText.length; // If not fully shown, it's skippable if( !isFullyShown ) { if( keysDown.isFirstPress( SPACE ) || keysDown.isFirstPress( ENTER ) ) { activeTextStartTime = 1; // A truty value a long time in the past newState.visibleText = generateText( currentText, Infinity ); } // Else do next text condition } else if( isFullyShown && keysDown.isFirstPress( ENTER ) ) { textQueue = textQueue.slice( 1 ); // No more text? close if( !textQueue.length ) { newState.visibleText = ''; textCloseStartTime = time; textIsClosing = true; // More text? set new active time } else { activeTextStartTime = time; } } } } // Otherwise is the text box still open? animate it closed if( textCloseStartTime ) { const timeSinceTextClosing = time - textCloseStartTime; newState.textOpenPercent = 1 - ( timeSinceTextClosing / textCloseTime ); // Reset everything if( newState.textOpenPercent <= 0 ) { textQueue = textQueue.slice( 1 ); textCloseStartTime = null; textIsVisible = false; textIsClosing = false; newState.textOpenPercent = 0; activeTextStartTime = null; textVisibleStartTime = null; } } newState = { ...newState, textVisibleStartTime, textIsVisible, activeTextStartTime, textQueue, textCloseStartTime, textIsClosing, }; return next({ ...currentState, ...newState }); }
packages/material-ui-icons/src/AlarmOn.js
cherniavskii/material-ui
import React from 'react'; import createSvgIcon from './utils/createSvgIcon'; export default createSvgIcon( <g><path d="M22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7zm-1.46-5.47L8.41 12.4l-1.06 1.06 3.18 3.18 6-6-1.06-1.06-4.93 4.95z" /></g> , 'AlarmOn');
app/routes.js
cdiezmoran/AlphaStage-2.0
/* eslint flowtype-errors/show-errors: 0 */ import React from 'react'; import { Switch, Route } from 'react-router'; import PropTypes from 'prop-types'; import App from './containers/App'; import BrowsePage from './containers/BrowsePage'; import GamePage from './containers/GamePage'; import CreateGamePage from './containers/CreateGamePage'; import DashboardPage from './containers/DashboardPage'; import CategoryPage from './containers/CategoryPage'; const Routes = ({ history }) => ( <App history={history}> <Switch> <Route path="/categories/:category" component={CategoryPage} /> <Route exact path="/dashboard" component={DashboardPage} /> <Route path="/games/new" component={CreateGamePage} /> <Route path="/games/edit/:id" component={CreateGamePage} /> <Route path="/games/:id" component={GamePage} /> <Route path="/" component={BrowsePage} /> </Switch> </App> ); Routes.propTypes = { history: PropTypes.object.isRequired }; export default Routes;
src/components/ReactSignupLoginComponent.js
akiokio/ReactSignupLoginComponent
import PropTypes from 'prop-types'; import React from 'react'; import Login from './Login'; import Signup from './Signup'; import RecoverPassword from './RecoverPassword'; // Our only css dependency import './normalize.css'; class ReactSignupLoginComponent extends React.Component { constructor(props) { super(props); this.updateState = this.updateState.bind(this); this.bubleUpSignup = this.bubleUpSignup.bind(this); this.bubleUpLogin = this.bubleUpLogin.bind(this); this.bubleUpRecoverPassword = this.bubleUpRecoverPassword.bind(this); this.state = { isLogin: this.props.isLogin, isRecoveringPassword: this.props.isRecoveringPassword, username: '', password: '', passwordConfirmation: '', }; } updateState(key, value) { this.setState({ [key]: value }); } bubleUpSignup() { this.props.handleSignup({ username: this.state.username, password: this.state.password, passwordConfirmation: this.state.passwordConfirmation, }); } bubleUpLogin() { this.props.handleLogin({ username: this.state.username, password: this.state.password, }); } bubleUpRecoverPassword() { this.props.handleRecoverPassword({ username: this.state.username, }); } render() { const styles = { wrapper: { border: '1px solid #eee', borderRadius: 3, backgroundColor: '#FAFAFA', margin: 10, padding: 20, maxWidth: '500px', width: 500, height: 400, perspective: 1000, }, title: { textAlign: 'center', height: 40, lineHeight: '40px', }, flipper: { transition: '0.4s', transformStyle: 'preserve-3d', position: 'relative', transform: `rotateY(${!this.state.isLogin || this.state.isRecoveringPassword ? '180' : '0'}deg)`, }, }; const showCard = () => { if (this.state.isLogin && !this.state.isRecoveringPassword) { return ( <Login key="login-form" handleShowSignup={this.updateState} handleShowRecover={this.updateState} styles={this.props.styles.login} handleLogin={this.bubleUpLogin} handleChange={this.updateState} username={this.state.username} password={this.state.password} usernameCustomLabel={this.props.usernameCustomLabel} passwordCustomLabel={this.props.passwordCustomLabel} recoverPasswordCustomLabel={this.props.recoverPasswordCustomLabel} goToSignupCustomLabel={this.props.goToSignupCustomLabel} submitLoginCustomLabel={this.props.submitLoginCustomLabel} /> ); } else if (!this.state.isLogin && !this.state.isRecoveringPassword) { return ( <Signup key="signup-form" handleShowLogin={this.updateState} styles={this.props.styles.signup} handleSignup={this.bubleUpSignup} handleChange={this.updateState} username={this.state.username} password={this.state.password} passwordConfirmation={this.state.passwordConfirmation} usernameCustomLabel={this.props.usernameCustomLabel} passwordCustomLabel={this.props.passwordCustomLabel} passwordConfirmationCustomLabel={this.props.passwordConfirmationCustomLabel} goToLoginCustomLabel={this.props.goToLoginCustomLabel} submitSignupCustomLabel={this.props.submitSignupCustomLabel} /> ); } return ( <RecoverPassword handleShowLogin={this.updateState} handleRecoverPassword={this.bubleUpRecoverPassword} handleChange={this.updateState} styles={this.props.styles.recoverPassword} username={this.state.username} usernameCustomLabel={this.props.usernameCustomLabel} goToLoginCustomLabel={this.props.goToLoginCustomLabel} submitRecoverPasswordCustomLabel={this.props.submitRecoverPasswordCustomLabel} /> ); }; return ( <section id="main-wrapper" style={Object.assign(styles.wrapper, this.props.styles.mainWrapper)} > <h1 style={Object.assign(styles.title, this.props.styles.mainTitle)}>{this.props.title}</h1> <div style={Object.assign(styles.flipper, this.props.styles.flipper)}>{showCard()}</div> </section> ); } } ReactSignupLoginComponent.propTypes = { title: PropTypes.string, isLogin: PropTypes.bool, isRecoveringPassword: PropTypes.bool, styles: PropTypes.shape({ mainWrapper: PropTypes.object, mainTitle: PropTypes.object, flipper: PropTypes.object, signup: PropTypes.shape({ wrapper: PropTypes.object, inputWrapper: PropTypes.object, buttonsWrapper: PropTypes.object, input: PropTypes.object, recoverPassword: PropTypes.object, button: PropTypes.object, }), login: PropTypes.shape({ wrapper: PropTypes.object, inputWrapper: PropTypes.object, buttonsWrapper: PropTypes.object, input: PropTypes.object, recoverPasswordWrapper: PropTypes.object, recoverPasswordButton: PropTypes.object, button: PropTypes.object, }), recoverPassword: PropTypes.shape({ wrapper: PropTypes.object, inputWrapper: PropTypes.object, buttonsWrapper: PropTypes.object, input: PropTypes.object, button: PropTypes.object, }), }), handleSignup: PropTypes.func.isRequired, handleLogin: PropTypes.func.isRequired, handleRecoverPassword: PropTypes.func.isRequired, usernameCustomLabel: PropTypes.string, passwordCustomLabel: PropTypes.string, passwordConfirmationCustomLabel: PropTypes.string, recoverPasswordCustomLabel: PropTypes.string, goToSignupCustomLabel: PropTypes.string, submitLoginCustomLabel: PropTypes.string, goToLoginCustomLabel: PropTypes.string, submitSignupCustomLabel: PropTypes.string, submitRecoverPasswordCustomLabel: PropTypes.string, }; ReactSignupLoginComponent.defaultProps = { title: 'Company Name', isLogin: true, isRecoveringPassword: false, styles: {}, usernameCustomLabel: 'Username', passwordCustomLabel: 'Password', passwordConfirmationCustomLabel: 'Confirm password', recoverPasswordCustomLabel: 'Recover Password', goToSignupCustomLabel: 'Signup', goToLoginCustomLabel: 'Login', submitLoginCustomLabel: 'Signup', submitSignupCustomLabel: 'Signup', submitRecoverPasswordCustomLabel: 'Recover', }; export default ReactSignupLoginComponent;
src/components/NotFoundPage/NotFoundPage.js
elurye/ReactJestBoiler
/* * React.js Starter Kit * Copyright (c) 2014 Konstantin Tarkus (@koistya), KriaSoft LLC. * * This source code is licensed under the MIT license found in the * LICENSE.txt file in the root directory of this source tree. */ 'use strict'; //require('./NotFoundPage.less'); import React, { Component } from 'react'; class NotFoundPage extends Component { render() { return ( <div> <h1>Page Not Found</h1> <p>Sorry, but the page you were trying to view does not exist.</p> </div> ); } } export default NotFoundPage;
201601react/许海英/react/app/components/button/button.js
zhufengreact/homework
import React, { Component } from 'react'; class Button extends Component { handleClick(){ alert('戳我干嘛!'); } render(){ const style = require('./button.less'); return ( <button className="my-button" onClick={this.handleClick.bind(this)}> 快戳我 </button> ); } } export default Button;
examples/auth-with-shared-root/components/Landing.js
shunitoh/react-router
import React from 'react' const Landing = React.createClass({ render() { return ( <div> <h1>Landing Page</h1> <p>This page is only shown to unauthenticated users.</p> <p>Partial / Lazy loading. Open the network tab while you navigate. Notice that only the required components are downloaded as you navigate around.</p> </div> ) } }) module.exports = Landing
app/components/Commissioned/CommissionedWork.js
1Green/projectAout
import React from 'react'; import { Link } from 'react-router'; import { RouteTransition } from 'react-router-transition'; export default React.createClass({ getInitialState(){ return { photoCategories: [], videoCategories: [] } }, componentWillMount(){ fetch('http://localhost:3000/API/commissionedWorkImages/') .then(data => data.json()) .then(data => this.setState({ photoCategories: data })); fetch('http://localhost:3000/API/commissionedWorkVideos/') .then(data => data.json()) .then(data => this.setState({ videoCategories: data })); }, render(){ const { photoCategories, videoCategories } = this.state; const isPhotoSelected = this.props.location.pathname.includes('photos'); const isVideoSelected = this.props.location.pathname.includes('videos'); const selectedStyle = {transform: "scale(1.3)", color:"white"}; return ( <div className="work-container"> <Link to="/CommissionedWork/photos"> <h1> Commissioned Work </h1> </Link> <div className="work-menu"> <Link to="/CommissionedWork/photos"> <p style={ isPhotoSelected ? selectedStyle : null } >Photos</p> </Link> <Link to="/CommissionedWork/videos"> <p style={ isVideoSelected ? selectedStyle : null } >Videos</p> </Link> </div> <RouteTransition pathname={this.props.location.pathname} atEnter={{ opacity: 0 }} atLeave={{ opacity: 1 }} atActive={{ opacity: 1 }} > { this.props.children && React.cloneElement(this.props.children, { photos : photoCategories, videos : videoCategories }) } </RouteTransition> </div> ) } })
resource/csdk/stack/samples/webos/com.example.app.iotivity/src/App/App.js
iotivity/iotivity
import kind from '@enact/core/kind'; import MoonstoneDecorator from '@enact/moonstone/MoonstoneDecorator'; import Panels from '@enact/moonstone/Panels'; import React from 'react'; import MainPanel from '../views/MainPanel'; import css from './App.less'; const App = kind({ name: 'App', styles: { css, className: 'app' }, render: (props) => ( <div {...props}> <Panels> <MainPanel /> </Panels> </div> ) }); export default MoonstoneDecorator(App);
src/index.js
uiureo/react-outside-event
import React from 'react'; import ReactDOM from 'react'; /** * @param {ReactClass} Target The component that defines `onOutsideEvent` handler. * @param {String[]} supportedEvents A list of valid DOM event names. Default: ['mousedown']. * @return {ReactClass} */ export default (Target, supportedEvents = ['mousedown']) => { return class ReactOutsideEvent extends React.Component { componentDidMount = () => { if (!this.refs.target.onOutsideEvent) { throw new Error('Component does not defined "onOutsideEvent" method.'); } supportedEvents.forEach((eventName) => { window.addEventListener(eventName, this.handleEvent, false); }); }; componentWillUnmount = () => { supportedEvents.forEach((eventName) => { window.removeEventListener(eventName, this.handleEvent, false); }); }; handleEvent = (event) => { let target, targetElement, isInside, isOutside; target = this.refs.target; targetElement = ReactDOM.findDOMNode(target); isInside = targetElement.contains(event.target) || targetElement === event.target; isOutside = !isInside; if (isOutside) { target.onOutsideEvent(event); } }; render() { return <Target ref='target' {... this.props} />; } } };
packages/components/src/List/Toolbar/SelectAll/SelectAll.component.js
Talend/ui
import PropTypes from 'prop-types'; import React from 'react'; import classNames from 'classnames'; import getDefaultT from '../../../translate'; import theme from './SelectAll.scss'; function SelectAll({ id, items, isSelected, onToggleAll, t }) { const isAllSelected = () => items.length > 0 && items.findIndex(item => !isSelected(item)) < 0; const checkboxId = id && `${id}-check-all`; return ( <form className={classNames(theme.container, 'navbar-form navbar-left')}> <div className={classNames('checkbox-inline navbar-text', theme['tc-list-toolbar-select-all'])} > <label className="tc-list-toolbar-select-all" htmlFor={checkboxId}> <input id={checkboxId} type="checkbox" onChange={event => { onToggleAll(event, items); }} checked={isAllSelected()} disabled={!items.length} /> <span>{t('LIST_SELECT_ALL', { defaultValue: 'Select All' })}</span> </label> </div> </form> ); } SelectAll.propTypes = { id: PropTypes.string, items: PropTypes.arrayOf(PropTypes.object).isRequired, isSelected: PropTypes.func.isRequired, onToggleAll: PropTypes.func.isRequired, t: PropTypes.func, }; SelectAll.defaultProps = { t: getDefaultT(), }; export default SelectAll;
src/routes/app.js
hrSoft-FE/mobile-vote
import React from 'react' import { connect } from 'dva' import NProgress from 'nprogress' import Layout from '../components/layout/main.jsx' const App = (props) => { const {children, loading, location} = props NProgress.start() !loading.global && NProgress.done() return ( <Layout children={children} location={location}> {children} </Layout> ) } export default connect(({loading, app}) => ({loading, app}))(App)
js/Quadrat.js
nathanjameshill/ReefWatchPrototype
import React from 'react' import { Grid, Col, Row } from 'react-bootstrap' import CustomGrid from './components/GridControl/Grid' import * as services from "../data/services" export default class Quadrat extends React.Component { constructor(props) { super(props); this.state = { observationId: this.props.params.observationId, columnData: [], rows: [], loaded: false } this.loadColumnData(); } componentDidUpdate() { if(!this.state.loaded && this.state.rows.length>0) { this.setState({loaded: true}); this.loadData(); } } loadData() { services.GetQuadrats(this.state.observationId, (quadrat) => { let rows = this.state.rows; console.log("State.rows->"); console.log(rows); rows.forEach((row, index) => { console.log("saved quadrat->"); console.log(quadrat); quadrat.forEach((item, index) => { console.log("Compare row.quadratRangeId:"+row['quadratRangeId']+" saved item.quadratRangeId:"+item.quadratRangeId) if (row['quadratRangeId']==item.quadratRangeId) { console.log("set "+item.quadratSpeciesId+" to "+item.count); row[item.quadratSpeciesId] = item.count; } //console.log("item ->"); //console.log(item); }); }); this.setState({rows: rows}); }); } loadColumnData() { services.GetQuadratSpecies((quadratSpecies) => { let columns = []; columns.push({ fieldName: "distance", ChangeEvent: (key, row, e) => this.onChange(key, row, e), IsKey: true, columnHeaderText: "", IsVertical: false, controlType: "display", IsRowHeader: true }); columns.push({ fieldName: "quadratRangeId", isHidden: "none", controlType: "hidden" }); quadratSpecies.forEach((item, index) => { let column = { fieldName: item.id, ChangeEvent: (key, row, e) => this.onChange(key, row, e), columnHeaderText: item.name, IsVertical: true, controlType: "number"}; columns.push(column) }) this.loadQuadRange(columns); }) } loadQuadRange(columns) { services.GetQuadratRange((QuadratRange) => { var rows = []; QuadratRange.forEach((item, index) => { var row = {}; columns.forEach((column, index) => { if(column.fieldName=='distance') { row['distance'] = item.range; } else if(column.fieldName=='quadratRangeId') { row['quadratRangeId'] = item.id; } else { row[column.fieldName] = 0; } }) rows.push(row); }) this.setState({ columnData: columns, rows: rows }); }) } onChange(key, row, e) { var rows = this.state.rows; var value = e.target.value.replace(/[^0-9]/g, ''); row[key] = value; this.setState({rows: rows}); this.saveCell(key, value, row, this.state.observationId); } saveCell(key, value, row, observationId) { let cell = { "count": value, "observationId": observationId, "quadratSpeciesId": key, "quadratRangeId": row['quadratRangeId'] }; services.upsertQuadrat(cell, (result) => { console.log(result); }); } validateNumber(value) { if (isNaN(value)) { return 'Please only enter numbers.' } return true; } render() { return ( <Grid> <Row> <Col md={12}> <h2>Species Quadrat Survey</h2> </Col> </Row> <Row> <Col md={12}> <CustomGrid data={this.state} /> </Col> </Row> </Grid> ) } }
src/components/TodoList.js
stevewillard/relay-todomvc
import React from 'react'; import Relay from 'react-relay'; import MarkAllTodosMutation from '../mutations/MarkAllTodosMutation'; import Todo from './Todo'; class TodoList extends React.Component { static propTypes = { viewer: React.PropTypes.object.isRequired }; onToggleAllChange = (e) => { const {viewer} = this.props; const {todos} = viewer; const complete = e.target.checked; Relay.Store.update( new MarkAllTodosMutation({viewer, todos, complete}) ); }; renderTodos() { const {viewer} = this.props; return viewer.todos.edges.map(({node}) => <Todo key={node.id} viewer={viewer} todo={node} /> ); } render() { const {numTodos, numCompletedTodos} = this.props.viewer.todos; if (!numTodos) { return null; } return ( <section className="main"> <input type="checkbox" checked={numTodos === numCompletedTodos} className="toggle-all" onChange={this.onToggleAllChange} /> <label htmlFor="toggle-all"> Mark all as complete </label> <ul className="todo-list"> {this.renderTodos()} </ul> </section> ); } } // In practice to optimally use the capacities of Relay's mutations, you'd use // separate activeTodos and completedTodos connections and modify them // separately in mutations. I'm using a single todos connection with a complete // argument to demonstrate how to pass variables down from the route, though. export default Relay.createContainer(TodoList, { initialVariables: { status: null }, prepareVariables({status}) { let complete; if (status === 'active') { complete = false; } else if (status === 'completed') { complete = true; } else { complete = null; } return {complete}; }, fragments: { viewer: () => Relay.QL` fragment on User { todos(complete: $complete, first: 9007199254740991) { edges { node { id, ${Todo.getFragment('todo')} } } numTodos, numCompletedTodos, ${MarkAllTodosMutation.getFragment('todos')} }, ${Todo.getFragment('viewer')}, ${MarkAllTodosMutation.getFragment('viewer')} } ` } });
app/util/short-aliases.js
igr-santos/hub-client
import React from 'react' import { Route } from 'react-router' export const r = (path, component) => <Route path={path} component={component} />
js/components/icon/index.js
soltrinox/MarketAuth.ReactNative
import React, { Component } from 'react'; import { connect } from 'react-redux'; import { Container, Header, Title, Content, Button, Icon, View } from 'native-base'; import { openDrawer } from '../../actions/drawer'; import styles from './styles'; class NHForm extends Component { // eslint-disable-line static propTypes = { openDrawer: React.PropTypes.func, } render() { return ( <Container style={styles.container}> <Header> <Title>Icons</Title> <Button transparent onPress={this.props.openDrawer}> <Icon name="ios-menu" /> </Button> </Header> <Content padder> <View style={styles.iconContainer} > <Icon name="logo-apple" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-pizza" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-person-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-beer" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-bicycle" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-navigate-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-cloud-circle" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-pie-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-bookmarks-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-pulse" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-camera-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-mic-off" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-film" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-flame" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-paper-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-paper-plane" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-speedometer-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-cart-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-flask-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-cloudy-night" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-partly-sunny" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-paw-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-rose" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-pint-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-shuffle" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-game-controller-a" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-glasses-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-microphone" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-keypad" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-color-filter-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-eye-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-mic-off" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-alarm-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-medkit" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-ionic-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-star-half" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-refresh" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-train" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-musical-notes" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-wine" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-nutrition" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-thunderstorm-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-grid-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-settings" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-chatbubbles" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-chatboxes" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-cog-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-baseball-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-bulb-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-calculator" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-rainy" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-videocam-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-play-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-disc-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-body" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-lock" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-skip-backward-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-key" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-flag-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-skip-forward" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-barcode-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="logo-tux" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-copy-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-stopwatch" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-medical-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-archive" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-bookmark" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-clipboard" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-happy" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-share" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-bluetooth" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-search" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-wifi" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-hand-outline" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-trash" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-images" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="ios-attach" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="logo-facebook" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="logo-googleplus" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="logo-twitter" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="logo-github" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="logo-whatsapp" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="logo-wordpress" style={{ width: 45, height: 45, justifyContent: 'center' }} /> <Icon name="logo-youtube" style={{ width: 45, height: 45, justifyContent: 'center' }} /> </View> </Content> </Container> ); } } function bindAction(dispatch) { return { openDrawer: () => dispatch(openDrawer()), }; } const mapStateToProps = state => ({ navigation: state.cardNavigation, }); export default connect(mapStateToProps, bindAction)(NHForm);
src/svg-icons/action/settings-backup-restore.js
kittyjumbalaya/material-components-web
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionSettingsBackupRestore = (props) => ( <SvgIcon {...props}> <path d="M14 12c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2zm-2-9c-4.97 0-9 4.03-9 9H0l4 4 4-4H5c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.51 0-2.91-.49-4.06-1.3l-1.42 1.44C8.04 20.3 9.94 21 12 21c4.97 0 9-4.03 9-9s-4.03-9-9-9z"/> </SvgIcon> ); ActionSettingsBackupRestore = pure(ActionSettingsBackupRestore); ActionSettingsBackupRestore.displayName = 'ActionSettingsBackupRestore'; ActionSettingsBackupRestore.muiName = 'SvgIcon'; export default ActionSettingsBackupRestore;
src/website/app/demos/Tooltip/Tooltip/examples/placement.js
mineral-ui/mineral-ui
/* @flow */ import styled from '@emotion/styled'; import IconDelete from 'mineral-ui-icons/IconDelete'; import React from 'react'; import Button from '../../../../../../library/Button'; import Tooltip from '../../../../../../library/Tooltip'; import type { StyledComponent } from '@emotion/styled-base/src/utils'; const Root: StyledComponent<{ [key: string]: any }> = styled('div')({ height: '200px', display: 'flex', alignItems: 'center', justifyContent: 'center' }); const DemoLayout = (props: Object) => <Root {...props} />; export default { id: 'placement', title: 'Placement', description: `The \`placement\` prop determines the initial placement of the Tooltip content relative to the trigger. The Tooltip will still react to viewport edges and scrolling.`, scope: { Button, DemoLayout, IconDelete, Tooltip }, source: ` <DemoLayout> <Tooltip content="Light years star stuff harvesting star light citizens of distant epochs." isOpen placement="bottom"> <Button variant="danger" iconStart={<IconDelete title="delete" />}/> </Tooltip> </DemoLayout>` };
node_modules/react-bootstrap/es/Radio.js
joekay/awebb
import _extends from 'babel-runtime/helpers/extends'; import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import classNames from 'classnames'; import React from 'react'; import PropTypes from 'prop-types'; import warning from 'warning'; import { bsClass, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils'; var propTypes = { inline: PropTypes.bool, disabled: PropTypes.bool, /** * Only valid if `inline` is not set. */ validationState: PropTypes.oneOf(['success', 'warning', 'error', null]), /** * Attaches a ref to the `<input>` element. Only functions can be used here. * * ```js * <Radio inputRef={ref => { this.input = ref; }} /> * ``` */ inputRef: PropTypes.func }; var defaultProps = { inline: false, disabled: false }; var Radio = function (_React$Component) { _inherits(Radio, _React$Component); function Radio() { _classCallCheck(this, Radio); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } Radio.prototype.render = function render() { var _props = this.props, inline = _props.inline, disabled = _props.disabled, validationState = _props.validationState, inputRef = _props.inputRef, className = _props.className, style = _props.style, children = _props.children, props = _objectWithoutProperties(_props, ['inline', 'disabled', 'validationState', 'inputRef', 'className', 'style', 'children']); var _splitBsProps = splitBsProps(props), bsProps = _splitBsProps[0], elementProps = _splitBsProps[1]; var input = React.createElement('input', _extends({}, elementProps, { ref: inputRef, type: 'radio', disabled: disabled })); if (inline) { var _classes2; var _classes = (_classes2 = {}, _classes2[prefix(bsProps, 'inline')] = true, _classes2.disabled = disabled, _classes2); // Use a warning here instead of in propTypes to get better-looking // generated documentation. process.env.NODE_ENV !== 'production' ? warning(!validationState, '`validationState` is ignored on `<Radio inline>`. To display ' + 'validation state on an inline radio, set `validationState` on a ' + 'parent `<FormGroup>` or other element instead.') : void 0; return React.createElement( 'label', { className: classNames(className, _classes), style: style }, input, children ); } var classes = _extends({}, getClassSet(bsProps), { disabled: disabled }); if (validationState) { classes['has-' + validationState] = true; } return React.createElement( 'div', { className: classNames(className, classes), style: style }, React.createElement( 'label', null, input, children ) ); }; return Radio; }(React.Component); Radio.propTypes = propTypes; Radio.defaultProps = defaultProps; export default bsClass('radio', Radio);
docs-ui/components/tagsTable.stories.js
beeftornado/sentry
import React from 'react'; import {withInfo} from '@storybook/addon-info'; import {text} from '@storybook/addon-knobs'; import TagsTable from 'app/components/tagsTable'; const event = { id: 'deadbeef', tags: [ {value: 'prod', key: 'environment', _meta: null}, {value: 'info', key: 'level', _meta: null}, {value: '1449204', key: 'project', _meta: null}, {value: '72ee409ef6df14396e6a608abbcd017aa374e497', key: 'release', _meta: null}, {value: 'CPython 2.7.16', key: 'runtime', _meta: null}, {value: 'CPython', key: 'runtime.name', _meta: null}, {value: 'worker-65881005', key: 'server_name', _meta: null}, {value: 'internal_error', key: 'status', _meta: null}, {value: 'sentry.tasks.store.save_event', key: 'task_name', _meta: null}, {value: '3c75bc89a4d4442b81af4cb41b6a1571', key: 'trace', _meta: null}, { value: '3c75bc89a4d4442b81af4cb41b6a1571-8662ecdaef1bbbaf', key: 'trace.ctx', }, {value: '8662ecdaef1bbbaf', key: 'trace.span', _meta: null}, {value: 'sentry.tasks.store.save_event', key: 'transaction', _meta: null}, ], }; export default { title: 'Core/Tables/TagsTable', }; export const Default = withInfo( 'Display a table of tags with each value as a link, generally to another search result.' )(() => { return ( <TagsTable title={text('title', 'Event Tags')} query="event.type:error" event={event} generateUrl={tag => `/issues/search?key=${tag.key}&value=${tag.value}`} /> ); }); Default.story = { name: 'default', };
src/containers/UsersContainer/UsersContainer.js
anvk/redux-portal-boilerplate
import React, { Component } from 'react'; import { connect } from 'react-redux'; import { Users } from '../../components'; import * as usersActions from '../../actions/usersActions.js'; class UsersContainer extends Component { render() { const { onSearch, ...props } = this.props; return <Users {...this.props} onSearch={onSearch} />; } } function mapStateToProps(state) { return { ...state.users }; } export default connect( mapStateToProps, { onSearch: usersActions.search } )(UsersContainer);
src/components/TalentStats.js
dfilipidisz/overfwolf-hots-talents
import React from 'react'; import { connect } from 'react-redux'; import AppPopup from './AppPopup'; const lvls = ['1', '4', '7', '10', '13', '16', '20']; const GraphIcon = ({lvl, openStatDetails}) => { const open = () => { openStatDetails(lvl); }; return ( <i className='fa fa-line-chart' onClick={open} /> ); }; const TalentStats = ({ data, selectedHero, heroTalentFilter, openStatDetails }) => { const hero = data[selectedHero]; const makeRow = (lvl) => { let topTalent = null; let topp = 0; hero[`lvl${lvl}`].forEach((talent) => { if (parseFloat(talent[heroTalentFilter]) > topp) { topp = parseFloat(talent[heroTalentFilter]); topTalent = Object.assign({}, talent); } }); return ( <div className='talent-row' key={`${lvl}-${heroTalentFilter}`}> <div className='lvl'><span>{lvl}</span></div> <div className='talent-holder clearfix'> <div className='img-holder'> <AppPopup position='right center' title={topTalent.title} > <div className={`talent-pic ${selectedHero} ${topTalent.id}`} /> </AppPopup> </div> <div className='text-holder'> <p>{heroTalentFilter === 'popularity' ? 'picked' : 'won'}</p> <p>% of time</p> </div> <div className='value-holder'> <span>{topTalent[heroTalentFilter]}%</span> </div> <div className='action-holder'> <GraphIcon lvl={lvl} openStatDetails={openStatDetails} /> </div> </div> </div> ); }; return ( <div className='talent-stats'> {lvls.map((lvl) => { return makeRow(lvl); })} </div> ); } export default connect( state => ({ heroTalentFilter: state.app.heroTalentFilter, }) )(TalentStats);
packages/mineral-ui-icons/src/IconColorLens.js
mineral-ui/mineral-ui
/* @flow */ import React from 'react'; import Icon from 'mineral-ui/Icon'; import type { IconProps } from 'mineral-ui/Icon/types'; /* eslint-disable prettier/prettier */ export default function IconColorLens(props: IconProps) { const iconProps = { rtl: false, ...props }; return ( <Icon {...iconProps}> <g> <path d="M12 3a9 9 0 0 0 0 18c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"/> </g> </Icon> ); } IconColorLens.displayName = 'IconColorLens'; IconColorLens.category = 'image';
packages/material-ui-docs/src/NProgressBar/NProgressBar.js
lgollut/material-ui
import React from 'react'; import PropTypes from 'prop-types'; import NProgress from 'nprogress'; import { withStyles } from '@material-ui/core/styles'; import NoSsr from '@material-ui/core/NoSsr'; import { exactProp } from '@material-ui/utils'; NProgress.configure({ template: ` <div class="nprogress-bar" role="bar"> <dt></dt> <dd></dd> </div> `, }); const styles = (theme) => { if (!theme.nprogress.color) { throw new Error( 'Material-UI: You need to provide a `theme.nprogress.color` property' + ' for using the `NProgressBar` component.', ); } return { '@global': { '#nprogress': { direction: 'ltr', pointerEvents: 'none', position: 'fixed', top: 0, left: 0, right: 0, height: 2, zIndex: theme.zIndex.tooltip, backgroundColor: '#e0e0e0', '& .nprogress-bar': { position: 'fixed', backgroundColor: theme.nprogress.color, top: 0, left: 0, right: 0, height: 2, }, '& dd, & dt': { position: 'absolute', top: 0, height: 2, boxShadow: `${theme.nprogress.color} 1px 0 6px 1px`, borderRadius: '100%', animation: 'mui-nprogress-pulse 2s ease-out 0s infinite', }, '& dd': { opacity: 0.6, width: 20, right: 0, clip: 'rect(-6px,22px,14px,10px)', }, '& dt': { opacity: 0.6, width: 180, right: -80, clip: 'rect(-6px,90px,14px,-6px)', }, }, '@keyframes mui-nprogress-pulse': { '30%': { opacity: 0.6, }, '60%': { opacity: 0, }, to: { opacity: 0.6, }, }, }, }; }; const GlobalStyles = withStyles(styles, { flip: false, name: 'MuiNProgressBar' })(() => null); /** * Elegant and ready to use wrapper on top of https://github.com/rstacruz/nprogress/. * The implementation is highly inspired by the YouTube one. */ function NProgressBar(props) { return ( <NoSsr> {props.children} <GlobalStyles /> </NoSsr> ); } NProgressBar.propTypes = { children: PropTypes.node, }; if (process.env.NODE_ENV !== 'production') { NProgressBar.propTypes = exactProp(NProgressBar.propTypes); } export default NProgressBar;
app-1/old-src/js/components/Product.js
alexisbellido/api-examples
import React from 'react'; class Product extends React.Component { // Class components should always call the base constructor with props. constructor (props) { // any time we define our own custom component methods, we have to manually bind this to the component ourselves. super(props); this.handleUpvote = this.handleUpvote.bind(this); } handleUpvote () { this.props.onVote(this.props.id); } handleWithEvent (e, id) { // e is the event console.log(`Handle with event id: ${id}`); e.preventDefault(); } render () { return ( <div className="item"> <div className="description"> <h2><a href="#">{this.props.id}: {this.props.title}</a></h2> <p> {this.props.description} | <a href="#" onClick={this.handleUpvote}>{this.props.votes} votes</a> </p> <p> <a href="#" onClick={(e) => this.handleWithEvent(e, this.props.id)}>Click preventing event</a> </p> </div> </div> ); } } Product.propTypes = { id: React.PropTypes.number.isRequired, title: React.PropTypes.string, votes: React.PropTypes.number, description: React.PropTypes.string, onVote: React.PropTypes.func }; export default Product;
Lumino/js/components/WrappedComponents/Switch.js
evonove/lumino
import React from 'react'; import PropTypes from 'prop-types'; import { Switch as NativeSwitch } from 'react-native'; const Switch = ({ input: { onChange, value }, ...custom }) => ( <NativeSwitch value={value === '' ? true : value} onValueChange={onChange} {...custom} /> ); Switch.propTypes = { input: PropTypes.object.isRequired, }; export default Switch;
src/svg-icons/action/work.js
pancho111203/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ActionWork = (props) => ( <SvgIcon {...props}> <path d="M20 6h-4V4c0-1.11-.89-2-2-2h-4c-1.11 0-2 .89-2 2v2H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-6 0h-4V4h4v2z"/> </SvgIcon> ); ActionWork = pure(ActionWork); ActionWork.displayName = 'ActionWork'; ActionWork.muiName = 'SvgIcon'; export default ActionWork;
docs/pages/Home/index.js
jossmac/react-images
// @flow // @jsx glam import glam from 'glam' import React, { Component } from 'react' import { type ProviderProps } from '../../ImageProvider' import { Code, CodeBlock, Heading, Title } from '../components' import PrettyProps from '../../PrettyProps' import GalleryExample from './GalleryExample' import { carouselProps, modalProps } from './props' export default class Home extends Component<ProviderProps> { render() { return ( <div> <Title>React Images</Title> <p> A mobile-friendly, highly customizable, carousel component for displaying media in ReactJS. Images courtesy of{' '} <a href="https://unsplash.com" target="_blank"> Unsplash </a> . </p> <h3>Getting Started</h3> <p> Start by installing <Code>react-images</Code> </p> <CodeBlock>yarn add react-images</CodeBlock> <h3>Using the Carousel</h3> <p> Import the carousel from <Code>react-images</Code> at the top of a component and then use it in the render function. </p> <CodeBlock>{`import React from 'react'; import Carousel from 'react-images'; const images = [{ source: 'path/to/image-1.jpg' }, { source: 'path/to/image-2.jpg' }]; class Component extends React.Component { render() { return <Carousel views={images} />; } }`}</CodeBlock> <h3>Using the Modal</h3> <p> Import the modal and optionally the modal gateway from <Code>react-images</Code> at the top of a component and then use it in the render function. </p> <p> The <Code>ModalGateway</Code> will insert the modal just before the end of your <Code>{'<body />'}</Code> tag. </p> <CodeBlock>{`import React from 'react'; import Carousel, { Modal, ModalGateway } from 'react-images'; const images = [{ src: 'path/to/image-1.jpg' }, { src: 'path/to/image-2.jpg' }]; class Component extends React.Component { state = { modalIsOpen: false } toggleModal = () => { this.setState(state => ({ modalIsOpen: !state.modalIsOpen })); } render() { const { modalIsOpen } = this.state; return ( <ModalGateway> {modalIsOpen ? ( <Modal onClose={this.toggleModal}> <Carousel views={images} /> </Modal> ) : null} </ModalGateway> ); } }`}</CodeBlock> <Heading source="/Home/GalleryExample.js">Example Gallery</Heading> <p> Below is a pretty typical implementation; the index of the selected thumbnail is passed to the <Code>currentIndex</Code> property of the carousel. All of the components, styles, getters, animations and functionality are the defaults provided by the library. </p> <GalleryExample {...this.props} /> <h2>Carousel Props</h2> {carouselProps.map(p => ( <PrettyProps key={p.name} {...p} /> ))} <h2>Modal Props</h2> {modalProps.map(p => ( <PrettyProps key={p.name} {...p} /> ))} </div> ) } }
web/static/app/components/App.js
jochakovsky/chores
import React from 'react'; import ChoreList from '../containers/ChoreList'; import AddChore from '../containers/AddChore'; import NavBar from '../components/NavBar'; import './App.css'; const App = () => ( <div> <NavBar /> <AddChore /> <ChoreList /> </div> ); export default App;
docs/src/app/components/pages/components/IconMenu/Page.js
xmityaz/material-ui
import React from 'react'; import Title from 'react-title-component'; import CodeExample from '../../../CodeExample'; import PropTypeDescription from '../../../PropTypeDescription'; import MarkdownElement from '../../../MarkdownElement'; import iconMenuReadmeText from './README'; import IconMenuExampleSimple from './ExampleSimple'; import iconMenuExampleSimpleCode from '!raw!./ExampleSimple'; import IconMenuExampleControlled from './ExampleControlled'; import iconMenuExampleControlledCode from '!raw!./ExampleControlled'; import IconMenuExampleScrollable from './ExampleScrollable'; import iconMenuExampleScrollableCode from '!raw!./ExampleScrollable'; import IconMenuExampleNested from './ExampleNested'; import iconMenuExampleNestedCode from '!raw!./ExampleNested'; import iconMenuCode from '!raw!material-ui/IconMenu/IconMenu'; const descriptions = { simple: 'Simple Icon Menus demonstrating some of the layouts possible using the `anchorOrigin` and `' + 'targetOrigin` properties.', controlled: 'Three controlled examples, the first allowing a single selection, the second multiple selections,' + ' the third using internal state.', scrollable: 'The `maxHeight` property limits the height of the menu, above which it will be scrollable.', nested: 'Example of nested menus within an IconMenu.', }; const IconMenusPage = () => ( <div> <Title render={(previousTitle) => `Icon Menu - ${previousTitle}`} /> <MarkdownElement text={iconMenuReadmeText} /> <CodeExample title="Icon Menu positioning" description={descriptions.simple} code={iconMenuExampleSimpleCode} > <IconMenuExampleSimple /> </CodeExample> <CodeExample title="Controlled Icon Menus" description={descriptions.controlled} code={iconMenuExampleControlledCode} > <IconMenuExampleControlled /> </CodeExample> <CodeExample title="Scrollable Icon Menu" description={descriptions.scrollable} code={iconMenuExampleScrollableCode} > <IconMenuExampleScrollable /> </CodeExample> <CodeExample title="Nested Icon Menus" description={descriptions.nested} code={iconMenuExampleNestedCode} > <IconMenuExampleNested /> </CodeExample> <PropTypeDescription code={iconMenuCode} /> </div> ); export default IconMenusPage;
examples/05 Customize/Handles and Previews/Container.js
jowcy/react-dnd
import React, { Component } from 'react'; import { DragDropContext } from 'react-dnd'; import HTML5Backend from 'react-dnd/modules/backends/HTML5'; import BoxWithImage from './BoxWithImage'; import BoxWithHandle from './BoxWithHandle'; @DragDropContext(HTML5Backend) export default class Container extends Component { render() { return ( <div> <div style={{ marginTop: '1.5rem' }}> <BoxWithHandle /> <BoxWithImage /> </div> </div> ); } }
addons/comments/src/manager/components/CommentItem/index.js
nfl/react-storybook
import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { window } from 'global'; import moment from 'moment'; import renderHTML from 'react-render-html'; import insertCss from 'insert-css'; import style from './style'; import commentCSS from './style.css'; insertCss(commentCSS); export default class CommentItem extends Component { constructor(props, ...args) { super(props, ...args); this.state = { hovered: false }; this.mouseEnter = this.mouseEnter.bind(this); this.mouseLeave = this.mouseLeave.bind(this); this.deleteComment = this.deleteComment.bind(this); } mouseEnter() { this.setState({ hovered: true }); } mouseLeave() { this.setState({ hovered: false }); } deleteComment() { const confirmDelete = window.confirm('Are you sure you want to delete this comment?'); if (confirmDelete === true) { this.props.deleteComment(); } } renderDelete() { return ( <a style={style.commentDelete} onClick={this.deleteComment} role="button" tabIndex="0"> delete </a> ); } render() { const comment = this.props.comment; let commentStyle = style.commentItem; if (comment.loading) { commentStyle = style.commentItemloading; } const time = moment(new Date(comment.time), 'YYYYMMDD').fromNow(); const body = renderHTML(`<span>${comment.text}</span>`); const showDelete = this.state.hovered && this.props.ownComment; return ( <div style={commentStyle} onMouseEnter={this.mouseEnter} onMouseLeave={this.mouseLeave}> <div style={style.commentAside}> <img alt={comment.user.name} style={style.commentAvatar} src={comment.user.avatar} /> </div> <div className="comment-content" style={style.commentContent}> <div style={style.commentHead}> <span style={style.commentUser}>{comment.user.name}</span> <span style={style.commentTime}>{time}</span> </div> <span style={style.commentText}>{body}</span> {showDelete ? this.renderDelete() : null} </div> </div> ); } } CommentItem.defaultProps = { comment: {}, deleteComment: () => {}, ownComment: false, }; CommentItem.propTypes = { deleteComment: PropTypes.func, comment: PropTypes.shape({ user: PropTypes.object, text: PropTypes.string, time: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]), loading: PropTypes.bool, }), ownComment: PropTypes.bool, };
src/svg-icons/content/remove-circle.js
kittyjumbalaya/material-components-web
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let ContentRemoveCircle = (props) => ( <SvgIcon {...props}> <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11H7v-2h10v2z"/> </SvgIcon> ); ContentRemoveCircle = pure(ContentRemoveCircle); ContentRemoveCircle.displayName = 'ContentRemoveCircle'; ContentRemoveCircle.muiName = 'SvgIcon'; export default ContentRemoveCircle;
src/js/components/icons/base/Rewind.js
kylebyerly-hp/grommet
// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import CSSClassnames from '../../../utils/CSSClassnames'; import Intl from '../../../utils/Intl'; import Props from '../../../utils/Props'; const CLASS_ROOT = CSSClassnames.CONTROL_ICON; const COLOR_INDEX = CSSClassnames.COLOR_INDEX; export default class Icon extends Component { render () { const { className, colorIndex } = this.props; let { a11yTitle, size, responsive } = this.props; let { intl } = this.context; const classes = classnames( CLASS_ROOT, `${CLASS_ROOT}-rewind`, className, { [`${CLASS_ROOT}--${size}`]: size, [`${CLASS_ROOT}--responsive`]: responsive, [`${COLOR_INDEX}-${colorIndex}`]: colorIndex } ); a11yTitle = a11yTitle || Intl.getMessage(intl, 'rewind'); const restProps = Props.omit(this.props, Object.keys(Icon.propTypes)); return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><polygon fill="none" stroke="#000" strokeWidth="2" points="22 3.5 22 20 13 14 13 20 2 12 13 4 13 10"/></svg>; } }; Icon.contextTypes = { intl: PropTypes.object }; Icon.defaultProps = { responsive: true }; Icon.displayName = 'Rewind'; Icon.icon = true; Icon.propTypes = { a11yTitle: PropTypes.string, colorIndex: PropTypes.string, size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']), responsive: PropTypes.bool };
client/pages/filespage/breadcrumb.js
mickael-kerjean/nuage
import React from 'react'; import PropTypes from 'prop-types'; import { DropTarget } from 'react-dnd'; import { EventEmitter, BreadCrumb, PathElement } from '../../components/'; import { pathBuilder, filetype, basename } from '../../helpers/'; export class BreadCrumbTargettable extends BreadCrumb { constructor(props){ super(props); } render(){ return super.render(Element); } } const fileTarget = { canDrop(props){ return props.isLast ? false : true; }, drop(props, monitor, component){ let src = monitor.getItem(); if(props.currentSelection.length === 0){ const from = pathBuilder(src.path, src.name, src.type); const to = pathBuilder(props.path.full, src.name, src.type); return {action: 'rename', args: [from, to, src.type], ctx: 'breadcrumb'}; } else { return {action: 'rename.multiple', args: props.currentSelection.map((selectionPath) => { const from = selectionPath; const to = pathBuilder( props.path.full, "./"+basename(selectionPath), filetype(selectionPath) ); return [from, to]; })}; } } } const nativeFileTarget = { canDrop(props){ return props.isLast ? false : true; }, drop: function(props, monitor){ let files = monitor.getItem(); props.emit('file.upload', props.path.full, files); } }; @EventEmitter @DropTarget('__NATIVE_FILE__', nativeFileTarget, (connect, monitor) => ({ connectNativeFileDropTarget: connect.dropTarget(), isNativeFileOver: monitor.isOver(), canDropFile: monitor.canDrop() })) @DropTarget('file', fileTarget, (connect, monitor) => ({ connectDropTarget: connect.dropTarget(), isOver: monitor.isOver(), canDrop: monitor.canDrop() })) class Element extends PathElement { constructor(props){ super(props) } render(){ let highlight = (this.props.isOver && this.props.canDrop ) || (this.props.isNativeFileOver && this.props.canDropFile); return this.props.connectNativeFileDropTarget(this.props.connectDropTarget( super.render(highlight) )); } }
src/svg-icons/notification/airline-seat-recline-extra.js
owencm/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let NotificationAirlineSeatReclineExtra = (props) => ( <SvgIcon {...props}> <path d="M5.35 5.64c-.9-.64-1.12-1.88-.49-2.79.63-.9 1.88-1.12 2.79-.49.9.64 1.12 1.88.49 2.79-.64.9-1.88 1.12-2.79.49zM16 19H8.93c-1.48 0-2.74-1.08-2.96-2.54L4 7H2l1.99 9.76C4.37 19.2 6.47 21 8.94 21H16v-2zm.23-4h-4.88l-1.03-4.1c1.58.89 3.28 1.54 5.15 1.22V9.99c-1.63.31-3.44-.27-4.69-1.25L9.14 7.47c-.23-.18-.49-.3-.76-.38-.32-.09-.66-.12-.99-.06h-.02c-1.23.22-2.05 1.39-1.84 2.61l1.35 5.92C7.16 16.98 8.39 18 9.83 18h6.85l3.82 3 1.5-1.5-5.77-4.5z"/> </SvgIcon> ); NotificationAirlineSeatReclineExtra = pure(NotificationAirlineSeatReclineExtra); NotificationAirlineSeatReclineExtra.displayName = 'NotificationAirlineSeatReclineExtra'; NotificationAirlineSeatReclineExtra.muiName = 'SvgIcon'; export default NotificationAirlineSeatReclineExtra;
docs/src/layouts/doc-wrapper.js
adrianleb/nuclear-js
import React from 'react' import Wrapper from './wrapper' import DocSidebar from '../components/doc-sidebar' import Nav from '../components/nav' export default React.createClass({ propTypes: { title: React.PropTypes.string.isRequired, contents: React.PropTypes.string.isRequired, }, render() { return ( <Wrapper title={this.props.title}> <Nav includeLogo={true} /> <div className="container"> <div className="docs-page row"> <DocSidebar navData={this.props.navData} sectionTitle="Docs" /> <div className="docs-page--contents col l8" dangerouslySetInnerHTML={{ __html: this.props.contents }}></div> </div> </div> </Wrapper> ) } })
src/svg-icons/file/file-upload.js
kasra-co/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let FileFileUpload = (props) => ( <SvgIcon {...props}> <path d="M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"/> </SvgIcon> ); FileFileUpload = pure(FileFileUpload); FileFileUpload.displayName = 'FileFileUpload'; FileFileUpload.muiName = 'SvgIcon'; export default FileFileUpload;
fields/types/url/UrlField.js
Redmart/keystone
import React from 'react'; import Field from '../Field'; import { Button, FormInput } from 'elemental'; module.exports = Field.create({ displayName: 'URLField', openValue () { var href = this.props.value; if (!href) return; if (!/^(mailto\:)|(\w+\:\/\/)/.test(href)) { href = 'http://' + href; } window.open(href); }, renderLink () { if (!this.props.value) return null; return ( <Button type="link" onClick={this.openValue} className="keystone-relational-button" title={'Open ' + this.props.value + ' in a new tab'}> <span className="octicon octicon-link" /> </Button> ); }, wrapField () { return ( <div style={{ position: 'relative' }}> {this.renderField()} {this.renderLink()} </div> ); }, renderValue () { return <FormInput noedit onClick={this.openValue}>{this.props.value}</FormInput>; } });
resources/js/components/FormInput/TextInput.js
DoSomething/northstar
import React from 'react'; import PropTypes from 'prop-types'; /** * Base text input. */ const TextInput = ({ attributes, className, clearErrors, id, name, placeholder, setData, value, }) => { function handleChange(event) { clearErrors(event.target.name); setData(event.target.name, event.target.value); } return ( <input className={className} data-testid="text-input-element" id={id} name={name || id} type="text" onChange={handleChange} placeholder={placeholder} value={value} {...attributes} /> ); }; TextInput.propTypes = { /** * Attributes to pass to the input element. */ attributes: PropTypes.object, /** * Classes to style the input element. */ className: PropTypes.string, /** * Method for clearing input errors. */ clearErrors: PropTypes.func.isRequired, /** * Identifier attribute for the input element. */ id: PropTypes.string.isRequired, /** * Name attribute for the input element; will default to the same value as ID if none provided. */ name: PropTypes.string, /** * Placeholder text for the input element. */ placeholder: PropTypes.string, /** * Method for setting value for data when input provided. */ setData: PropTypes.func.isRequired, /** * Value attribute for the input element. */ value: PropTypes.string.isRequired, }; TextInput.defaultProps = { attributes: {}, className: null, name: null, placeholder: null, }; export default TextInput;
app/javascript/mastodon/features/favourited_statuses/index.js
tateisu/mastodon
import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { fetchFavouritedStatuses, expandFavouritedStatuses } from '../../actions/favourites'; import Column from '../ui/components/column'; import ColumnHeader from '../../components/column_header'; import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import StatusList from '../../components/status_list'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { debounce } from 'lodash'; const messages = defineMessages({ heading: { id: 'column.favourites', defaultMessage: 'Favourites' }, }); const mapStateToProps = state => ({ statusIds: state.getIn(['status_lists', 'favourites', 'items']), isLoading: state.getIn(['status_lists', 'favourites', 'isLoading'], true), hasMore: !!state.getIn(['status_lists', 'favourites', 'next']), }); export default @connect(mapStateToProps) @injectIntl class Favourites extends ImmutablePureComponent { static propTypes = { dispatch: PropTypes.func.isRequired, shouldUpdateScroll: PropTypes.func, statusIds: ImmutablePropTypes.list.isRequired, intl: PropTypes.object.isRequired, columnId: PropTypes.string, multiColumn: PropTypes.bool, hasMore: PropTypes.bool, isLoading: PropTypes.bool, }; componentWillMount () { this.props.dispatch(fetchFavouritedStatuses()); } handlePin = () => { const { columnId, dispatch } = this.props; if (columnId) { dispatch(removeColumn(columnId)); } else { dispatch(addColumn('FAVOURITES', {})); } } handleMove = (dir) => { const { columnId, dispatch } = this.props; dispatch(moveColumn(columnId, dir)); } handleHeaderClick = () => { this.column.scrollTop(); } setRef = c => { this.column = c; } handleLoadMore = debounce(() => { this.props.dispatch(expandFavouritedStatuses()); }, 300, { leading: true }) render () { const { intl, shouldUpdateScroll, statusIds, columnId, multiColumn, hasMore, isLoading } = this.props; const pinned = !!columnId; const emptyMessage = <FormattedMessage id='empty_column.favourited_statuses' defaultMessage="You don't have any favourite toots yet. When you favourite one, it will show up here." />; return ( <Column ref={this.setRef} label={intl.formatMessage(messages.heading)}> <ColumnHeader icon='star' title={intl.formatMessage(messages.heading)} onPin={this.handlePin} onMove={this.handleMove} onClick={this.handleHeaderClick} pinned={pinned} multiColumn={multiColumn} showBackButton /> <StatusList trackScroll={!pinned} statusIds={statusIds} scrollKey={`favourited_statuses-${columnId}`} hasMore={hasMore} isLoading={isLoading} onLoadMore={this.handleLoadMore} shouldUpdateScroll={shouldUpdateScroll} emptyMessage={emptyMessage} /> </Column> ); } }
src/templates/blog-post.js
H3yfinn/finbarmaunsell.com
import React from 'react'; import Helmet from 'react-helmet'; import Footer from '../pages/components/footer.js'; import classifier_img from '../pages/classifier_test.png'; // import '../css/blog-post.css'; // make it pretty! export default function Template({ data // this prop will be injected by the GraphQL query we'll write in a bit }) { const { markdownRemark: post } = data; // data.markdownRemark holds our post data return ( <div className="blog-post-container"> <Helmet title={`${post.frontmatter.title}`} /> <div className="blog-post"> <h1> {post.frontmatter.title} </h1> <div className="blog-post-content" dangerouslySetInnerHTML={{ __html: post.html }} /> </div> <Footer /> </div> ); } export const pageQuery = graphql` query BlogPostByPath($path: String!) { markdownRemark(frontmatter: { path: { eq: $path } }) { html frontmatter { date(formatString: "MMMM DD, YYYY") path title } } } ` ;
ReduxThunkNews/src/app.js
fengnovo/webpack-react
import React from 'react' import ReactDOM from 'react-dom' import { Provider } from 'react-redux' import { createStore, applyMiddleware } from 'redux'; import thunkMiddleware from 'redux-thunk'; import { createLogger } from 'redux-logger'; import { reducers } from './js/reducers'; import injectTapEventPlugin from 'react-tap-event-plugin'; import './css/index.scss'; import App from './js/App'; injectTapEventPlugin(); const logger = createLogger(); const createStoreWithMiddleware = applyMiddleware( thunkMiddleware, logger )(createStore); const store = createStoreWithMiddleware(reducers); ReactDOM.render( <Provider store={store}> <App /> </Provider>, document.getElementById('app'));
examples/passing-props-to-children/app.js
brenoc/react-router
import React from 'react' import { render } from 'react-dom' import { createHistory, useBasename } from 'history' import { Router, Route, Link, History } from 'react-router' require('./app.css') const history = useBasename(createHistory)({ basename: '/passing-props-to-children' }) const App = React.createClass({ mixins: [ History ], getInitialState() { return { tacos: [ { name: 'duck confit' }, { name: 'carne asada' }, { name: 'shrimp' } ] } }, addTaco() { let name = prompt('taco name?') this.setState({ tacos: this.state.tacos.concat({ name }) }) }, handleRemoveTaco(removedTaco) { this.setState({ tacos: this.state.tacos.filter(function (taco) { return taco.name != removedTaco }) }) this.history.pushState(null, '/') }, render() { let links = this.state.tacos.map(function (taco, i) { return ( <li key={i}> <Link to={`/taco/${taco.name}`}>{taco.name}</Link> </li> ) }) return ( <div className="App"> <button onClick={this.addTaco}>Add Taco</button> <ul className="Master"> {links} </ul> <div className="Detail"> {this.props.children && React.cloneElement(this.props.children, { onRemoveTaco: this.handleRemoveTaco })} </div> </div> ) } }) const Taco = React.createClass({ remove() { this.props.onRemoveTaco(this.props.params.name) }, render() { return ( <div className="Taco"> <h1>{this.props.params.name}</h1> <button onClick={this.remove}>remove</button> </div> ) } }) render(( <Router history={history}> <Route path="/" component={App}> <Route path="taco/:name" component={Taco} /> </Route> </Router> ), document.getElementById('example'))
pages/people/dasabogals.js
pcm-ca/pcm-ca.github.io
import React from 'react' import { Link } from 'react-router' import Helmet from 'react-helmet' import { config } from 'config' import { prefixLink } from 'gatsby-helpers' import info from './info' import PersonPage from '../../components/PersonPage' export default class Index extends React.Component { render() { return ( <div> <Helmet title={config.siteTitle + ' | people | dasabogals'} /> <PersonPage {...info.dasabogals} picture="../images/dasabogals.jpg" /> </div> ) } }
src/index.js
bofa/demography-portal
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; ReactDOM.render(<App />, document.getElementById('root'));
src/ModalFooter.js
PeterDaveHello/react-bootstrap
import React from 'react'; import classnames from 'classnames'; class ModalFooter extends React.Component { render() { return ( <div {...this.props} className={classnames(this.props.className, this.props.modalClassName)}> {this.props.children} </div> ); } } ModalFooter.propTypes = { /** * A css class applied to the Component */ modalClassName: React.PropTypes.string }; ModalFooter.defaultProps = { modalClassName: 'modal-footer' }; export default ModalFooter;
frontend/src/containers/Blinker/Blinker.js
webrecorder/webrecorder
import React from 'react'; import { connect } from 'react-redux'; import BlinkerUI from 'components/BlinkerUI'; const mapStateToProps = ({ app }) => { const bytes = app.getIn(['infoStats', 'pending_size']) || 0; return { bytes }; }; export default connect( mapStateToProps )(BlinkerUI);
src/components/ShowMoreProducts/ShowMoreProducts.js
unam3/oshop
import React from 'react'; export const ShowMoreProducts = ({onShowMoreProducts}) => { require('./ShowMoreProducts.css'); return ( <a href="#" className="show-more text-color" onClick={ (e) => {e.preventDefault(); onShowMoreProducts(); } }> Показать еще 6 товаров </a> ); };
src/containers/VisionContainer.js
rexxars/sanity-vision
import React from 'react' import DelayedSpinner from '../components/DelayedSpinner' import ErrorDialog from '../components/ErrorDialog' import VisionGui from '../components/VisionGui' import LoadingContainer from './LoadingContainer' // Loads the most basic data from a Sanity project class VisionContainer extends LoadingContainer { getSubscriptions() { return { datasets: {uri: '/datasets'} } } render() { if (this.state.error) { return ( <ErrorDialog heading="An error occured while loading project data" error={this.state.error} /> ) } if (!this.hasAllData()) { return <DelayedSpinner /> } return <VisionGui {...this.state} /> } } export default VisionContainer
app/components/ContainerView.js
pbillerot/reacteur
'use strict'; import React from 'react' import ReactDOM from 'react-dom' import 'whatwg-fetch' import { Link } from 'react-router' import scrollIntoView from 'scroll-into-view' // W3 const { Alerter, Button, Card, Content, Footer, Header, IconButton , Menubar, Nav, Navbar, NavGroup, Sidebar, Window } = require('./w3.jsx') import ContainerPager from './ContainerPager' import { Dico } from '../config/Dico' import { Tools } from '../config/Tools' import { ToolsUI } from '../config/ToolsUI' export default class ContainerView extends React.Component { constructor(props) { super(props); this.state = { is_data_recepted: false, app: this.props.app, table: this.props.table, view: this.props.view, filter: '', page_total: 0, page_current: 0, rows: [], row_selected: null, is_error: false, error: { code: '', message: '' }, ctx: { elements: {}, session: this.props.ctx.session, } } this.handleFilterChanged = this.handleFilterChanged.bind(this) this.handleFilterSubmit = this.handleFilterSubmit.bind(this) this.handleSkipPage = this.handleSkipPage.bind(this) //console.log("ContainerView.constructor", this.state) } handleSkipPage(page) { //console.log("ContainerView.handleSkipPage", page, this.state) this.state.page_current = page sessionStorage.setItem(this.state.app + '_' + this.state.table + '_' + this.state.view + '_page_current', this.state.page_current); this.getData(this.state.app, this.state.table, this.state.view) } handleFilterChanged(e) { //console.log("ContainerView.handleFilterChanged", e.target.value) this.setState({ filter: e.target.value }) } handleFilterSubmit() { //console.log("ContainerView.handleFilterSubmit") sessionStorage.setItem(this.state.app + '_' + this.state.table + '_' + this.state.view + '_filter', this.state.filter); this.state.page_current = 0 sessionStorage.setItem(this.state.app + '_' + this.state.table + '_' + this.state.view + '_page_current', this.state.page_current); this.getData(this.state.app, this.state.table, this.state.view) } componentWillReceiveProps(nextProps) { //console.log('ContainerView.componentWillReceiveProps', nextProps.params) this.state.is_data_recepted = false this.state.app = nextProps.params ? nextProps.params.app : nextProps.app this.state.table = nextProps.params ? nextProps.params.table : nextProps.table this.state.view = nextProps.params ? nextProps.params.view : nextProps.view this.state.filter = sessionStorage.getItem(this.state.app + '_' + this.state.table + '_' + this.state.view + '_filter') if (this.state.filter == null) this.state.filter = '' let page_current = sessionStorage.getItem(this.state.app + '_' + this.state.table + '_' + this.state.view + '_page_current') if (page_current == null) this.state.page_current = 0 else this.state.page_current = parseInt(page_current) this.getData(this.state.app, this.state.table, this.state.view) } componentDidMount() { //console.log('ContainerView.componentDidMount...', this.state) this.state.filter = sessionStorage.getItem(this.state.app + '_' + this.state.table + '_' + this.state.view + '_filter') if (this.state.filter == null) this.state.filter = '' let page_current = sessionStorage.getItem(this.state.app + '_' + this.state.table + '_' + this.state.view + '_page_current') if (page_current == null) this.state.page_current = 0 else this.state.page_current = parseInt(page_current) this.getData(this.state.app, this.state.table, this.state.view) } getData(app, table, view) { if (Dico.apps[this.state.app] && Dico.apps[this.state.app].tables[this.state.table] && Dico.apps[this.state.app].tables[this.state.table].views[this.state.view]) { let key_id = Dico.apps[app].tables[table].key // recup du filtre et de la page courante dans la session du navigateur let data = 'filter=' + encodeURIComponent(this.state.filter) data += '&page_current=' + encodeURIComponent(this.state.page_current) if (this.props.where) { data += "&where=" + encodeURIComponent(this.props.where) } let url = '/api/view/' + app + '/' + table + '/' + view fetch(url, { method: "PUT", credentials: 'same-origin', headers: { 'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' }, body: data }) .then(response => { //console.log('response', response) response.json().then(json => { //console.log('json', json) //if ( json.alerts ) ToolsUI.showAlert(json.alerts) this.state.is_data_recepted = true if (response.ok == true) { let row_key = Dico.apps[app].tables[table].key this.state.ctx.elements = {} Object.keys(Dico.apps[app].tables[table].views[view].elements).forEach(key => { this.state.ctx.elements[key] = Object.assign({}, Dico.apps[app].tables[table].elements[key], Dico.apps[app].tables[table].views[view].elements[key]) }) //console.log(JSON.stringify(rows)) var tableur = [] json.rows.forEach((row) => { // insertion des colonnes des rubriques temporaires let ligne = {} let key_value = '' Object.keys(this.state.ctx.elements).forEach(key => { if (key == key_id) { key_value = row[key] //console.log("key_value", key_value) } if (Tools.isRubTemporary(key)) { //console.log("key", key_value) ligne[key] = key_value } else { ligne[key] = row[key] } }) tableur.push(ligne) }) //console.log(JSON.stringify(tableur)) this.setState({ rows_selected: [], rows: tableur, is_error: false, app: app, table: table, view: view, page_total: json.page_total }) } else { this.state.error = { code: json.code, message: json.message } this.setState({ is_error: true, app: app, table: table, view: view, }) } }) }) } } render() { let app = this.state.app let table = this.state.table let view = this.state.view let page_current = this.state.page_current let form_add = Dico.apps[app].tables[table].views[view].form_add let form_view = Dico.apps[app].tables[table].views[view].form_view let form_edit = Dico.apps[app].tables[table].views[view].form_edit let form_delete = Dico.apps[app].tables[table].views[view].form_delete let row_key = Dico.apps[app].tables[table].key let irow = 0 let icol = 0 Object.keys(this.state.ctx.elements).forEach(key => { if (!this.state.ctx.elements[key].is_hidden) { icol++ } }) if (form_view) icol++ if (form_edit) icol++ if (form_delete) icol++ //console.log("ContainerView.render", this.state.is_data_recepted) if (this.state.is_data_recepted) { return ( <div> {(!this.state.is_error && form_add && !this.props.where) && <Link to={'/form/add/' + app + '/' + table + '/' + view + '/' + form_add + '/0'}> <span className="w3-btn-floating-large w3-theme-action" title={'Ajout ' + Dico.apps[app].tables[table].forms[form_add].title + '...'} style={{ zIndex: 1000, position: 'fixed', top: '20px', right: '24px' }}>+</span> </Link> } <table className="w3-table-all w3-hoverable w3-medium w3-card-3"> <thead> {Dico.apps[app].tables[table].views[view].with_filter && <tr className="w3-theme-l4"> <td colSpan={icol}><div className="w3-row"> <div className="w3-col s3"> <Search {...this.props} filter={this.state.filter} handleFilterChanged={this.handleFilterChanged} handleFilterSubmit={this.handleFilterSubmit} /> </div> <div className="w3-col s9 w3-bar"> <ContainerPager {...this.props} key={view} className="w3-right" total={this.state.page_total} current={this.state.page_current} onSkipTo={this.handleSkipPage} /> <span className="w3-padding-8 w3-right" style={{ marginRight: '8px' }} >Page: </span> </div> </div> </td> </tr> } <tr className="w3-theme"> {form_view && <th>&nbsp;</th> } {form_edit && <th>&nbsp;</th> } { Object.keys(this.state.ctx.elements).map(key => <TH key={key} id={key} ctx={this.state.ctx} /> ) } {form_delete && <th>&nbsp;</th> } </tr> </thead> <tbody> { this.state.rows.map((row, i) => <Row key={i} containerView={this} row_key={row_key} ctx={this.state.ctx} app={app} table={table} view={view} form_view={form_view} form_edit={form_edit} form_delete={form_delete} row={row} /> ) } </tbody> </table> </div> ) } else { return null } } } class TH extends React.Component { render() { if (this.props.ctx.elements[this.props.id].is_hidden) { return null } else { return ( <th>{this.props.ctx.elements[this.props.id].label_short}</th> ) } } } class Row extends React.Component { constructor(props) { super(props) this.state = { row_selected: sessionStorage.getItem(this.props.app + '_' + this.props.table + '_' + this.props.view + '_row_selected') } this.handleClickRow = this.handleClickRow.bind(this) } handleClickRow(key_val) { //console.log("Row.handleClickRow", key_val) if (this.state.row_selected == key_val) { sessionStorage.removeItem(this.props.app + '_' + this.props.table + '_' + this.props.view + '_row_selected'); this.setState({ row_selected: null }) } else { sessionStorage.setItem(this.props.app + '_' + this.props.table + '_' + this.props.view + '_row_selected', key_val); this.setState({ row_selected: key_val }) } } componentDidMount() { //console.log('Row.componentDidMount', this.props.row[this.props.row_key]) if (this.props.row[this.props.row_key] == this.state.row_selected) { //ReactDOM.findDOMNode(this.node).scrollIntoView() scrollIntoView(this.node) } } // componentWillReceiveProps(nextProps) { // console.log('Row.componentWillReceiveProps...', nextProps) // if (nextProps) // this.state.row_selected = sessionStorage.getItem(this.nextProps.app + '_' + this.nextProps.table + '_' + this.nextProps.view + '_row_selected'); // } render() { let app = this.props.app let table = this.props.table let view = this.props.view let form_view = this.props.form_view let form_edit = this.props.form_edit let form_delete = this.props.form_delete let row = this.props.row let row_key = this.props.row_key let key_val = row[row_key] //console.log('Row: ',table + '->' + view, row_key + '=' + row[row_key], row) let icol = 0 let className = key_val == this.state.row_selected ? "w3-leftbar w3-rightbar w3-border w3-border-theme" : "" return ( <tr ref={node => this.node = node} onClick={() => this.handleClickRow(key_val)} className={className} > {form_view && <td style={{ width: '30px' }} > <Link to={'/form/view/' + app + '/' + table + '/' + view + '/' + form_view + '/' + key_val} title={'Voir ' + Dico.apps[app].tables[table].forms[form_view].title + '...'}> <i className="material-icons w3-text-blue-grey">visibility</i> </Link> </td> } {form_edit && <td style={{ width: '30px' }}> <Link to={'/form/edit/' + app + '/' + table + '/' + view + '/' + form_edit + '/' + key_val} title={'Modifier ' + Dico.apps[app].tables[table].forms[form_edit].title + '...'} ><i className="material-icons w3-text-teal">edit</i> </Link> </td> } { Object.keys(row).map(key => <TD key={icol++} ctx={this.props.ctx} row_key={row_key} id={key} table={table} view={view} row={row} /> ) } {form_delete && <td style={{ width: '30px' }}> <Link to={'/form/delete/' + app + '/' + table + '/' + view + '/' + form_delete + '/' + key_val} title={'Supprimer ' + Dico.apps[app].tables[table].forms[form_delete].title + '...'} ><i className="material-icons w3-text-orange">delete</i> </Link> </td> } </tr> ) } } class TD extends React.Component { render() { if (this.props.ctx.elements[this.props.id].is_hidden) { return null } else { return ( <td> <Cell ctx={this.props.ctx} row_key={this.props.row_key} id={this.props.id} table={this.props.table} view={this.props.view} row={this.props.row} /> </td> ) } } } class Cell extends React.Component { constructor(props) { super(props); } render() { let row = this.props.row let row_key = this.props.row_key let key_val = row[row_key] let id = this.props.id let val = row[id] let element = this.props.ctx.elements[id] let table = element.table ? element.table : this.props.table let view = element.view ? element.view : this.props.view let form = element.form ? element.form : this.props.form_edit //console.log('Cell:', table, view, id+'='+ val) switch (element.type) { case 'check': return ( <input className="w3-check" type="checkbox" disabled checked={val == '1' ? true : false} /> ) case 'radio': return ( <span>{element.list[val]}</span> ) case 'text': //let element = React.createElement('<span>A</span>', {}) if (element.display) { return (<span dangerouslySetInnerHTML={{ __html: element.display(val) }}></span>) } else { return <span>{val}</span> } default: return ( <span>{val}</span> ) } } } class Search extends React.Component { constructor(props) { super(props); state: { filter: '' } } render() { //console.log("Search", this.props.filter) return ( <div className="w3-row"> <span className="w3-col s9"> <input className="w3-input w3-border w3-small" name="filter" type="text" placeholder="recherche" onChange={this.props.handleFilterChanged} value={this.props.filter} id="filter" onKeyPress={(e) => { (e.key == 'Enter' ? this.props.handleFilterSubmit() : null) }} /> </span> <span className="w3-col s3 w3-padding-8"> <span className="" style={{ marginLeft: '8px', height: '100%' }} onClick={this.props.handleFilterSubmit} > <i className="w3-large fa fa-search"></i> </span> </span> </div> ) } }
src/components/dropdown/index.js
KleeGroup/focus-components
import PropTypes from 'prop-types'; import React, { Component } from 'react'; import ReactDOM from 'react-dom'; import uuid from 'uuid'; import ActionMenu from './action-menu'; /** * Dropdown component * * @class Dropdown * @extends {Component} */ class Dropdown extends Component { /** * Creates an instance of Dropdown. * @param {any} props component props * @memberof Dropdown */ constructor(props) { super(props); } /** @inheritdoc */ componentWillMount() { this._htmlId = uuid.v4(); } /** @inheritdoc */ render() { const { iconProps, operationList, position, shape } = this.props; const id = this._htmlId; if (0 === operationList.length) { return null; } return ( <ActionMenu id={id} iconProps={iconProps} operationList={operationList} position={position} shape={shape} /> ); } } Dropdown.displayName = 'Dropdown'; Dropdown.defaultProps = { position: 'right', iconProps: { name: 'more_vert' }, shape: 'icon', operationList: [] }; Dropdown.propTypes = { position: PropTypes.string, iconProps: PropTypes.object, operationList: PropTypes.array, shape: PropTypes.string }; export default Dropdown;
actor-apps/app-web/src/app/components/dialog/ComposeSection.react.js
bunnyblue/actor-platform
import _ from 'lodash'; import React from 'react'; import ReactMixin from 'react-mixin'; import addons from 'react/addons'; const {addons: { PureRenderMixin }} = addons; import ActorClient from 'utils/ActorClient'; import { Styles, FlatButton } from 'material-ui'; import { KeyCodes } from 'constants/ActorAppConstants'; import ActorTheme from 'constants/ActorTheme'; import MessageActionCreators from 'actions/MessageActionCreators'; import TypingActionCreators from 'actions/TypingActionCreators'; import DraftActionCreators from 'actions/DraftActionCreators'; import DraftStore from 'stores/DraftStore'; import AvatarItem from 'components/common/AvatarItem.react'; const ThemeManager = new Styles.ThemeManager(); const getStateFromStores = () => { return { text: DraftStore.getDraft(), profile: ActorClient.getUser(ActorClient.getUid()) }; }; @ReactMixin.decorate(PureRenderMixin) class ComposeSection extends React.Component { static propTypes = { peer: React.PropTypes.object.isRequired }; static childContextTypes = { muiTheme: React.PropTypes.object }; constructor(props) { super(props); this.state = getStateFromStores(); ThemeManager.setTheme(ActorTheme); DraftStore.addLoadDraftListener(this.onDraftLoad); } componentWillUnmount() { DraftStore.removeLoadDraftListener(this.onDraftLoad); } getChildContext() { return { muiTheme: ThemeManager.getCurrentTheme() }; } onDraftLoad = () => { this.setState(getStateFromStores()); } onChange = event => { TypingActionCreators.onTyping(this.props.peer); this.setState({text: event.target.value}); } onKeyDown = event => { if (event.keyCode === KeyCodes.ENTER && !event.shiftKey) { event.preventDefault(); this.sendTextMessage(); } else if (event.keyCode === 50 && event.shiftKey) { console.warn('Mention should show now.'); } } onKeyUp = () => { DraftActionCreators.saveDraft(this.state.text); } sendTextMessage = () => { const text = this.state.text; if (text) { MessageActionCreators.sendTextMessage(this.props.peer, text); } this.setState({text: ''}); DraftActionCreators.saveDraft('', true); } onSendFileClick = () => { const fileInput = document.getElementById('composeFileInput'); fileInput.click(); } onSendPhotoClick = () => { const photoInput = document.getElementById('composePhotoInput'); photoInput.accept = 'image/*'; photoInput.click(); } onFileInputChange = () => { const files = document.getElementById('composeFileInput').files; MessageActionCreators.sendFileMessage(this.props.peer, files[0]); } onPhotoInputChange = () => { const photos = document.getElementById('composePhotoInput').files; MessageActionCreators.sendPhotoMessage(this.props.peer, photos[0]); } onPaste = event => { let preventDefault = false; _.forEach(event.clipboardData.items, (item) => { if (item.type.indexOf('image') !== -1) { preventDefault = true; MessageActionCreators.sendClipboardPhotoMessage(this.props.peer, item.getAsFile()); } }, this); if (preventDefault) { event.preventDefault(); } } render() { const text = this.state.text; const profile = this.state.profile; return ( <section className="compose" onPaste={this.onPaste}> <AvatarItem image={profile.avatar} placeholder={profile.placeholder} title={profile.name}/> <textarea className="compose__message" onChange={this.onChange} onKeyDown={this.onKeyDown} onKeyUp={this.onKeyUp} value={text}> </textarea> <footer className="compose__footer row"> <button className="button" onClick={this.onSendFileClick}> <i className="material-icons">attachment</i> Send file </button> <button className="button" onClick={this.onSendPhotoClick}> <i className="material-icons">photo_camera</i> Send photo </button> <span className="col-xs"></span> <FlatButton label="Send" onClick={this.sendTextMessage} secondary={true}/> </footer> <div className="compose__hidden"> <input id="composeFileInput" onChange={this.onFileInputChange} type="file"/> <input id="composePhotoInput" onChange={this.onPhotoInputChange} type="file"/> </div> </section> ); } } export default ComposeSection;
src/routes/Mytracks/components/MyTracksView.js
synchu/schema
import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { List, Navigation } from 'react-toolbox' import Input from 'react-toolbox/lib/input' import SongItem from '../../../components/SongItem' import Infinite from 'react-infinite' import trackObject from '../interfaces/track.js' import classes from './MyTracksView.scss' import classNames from 'classnames' export class MyTracksView extends Component { static propTypes = { tracksCount: PropTypes.number, loadMoreTracks: PropTypes.func, tracks: PropTypes.array, isAuthenticated: PropTypes.bool.isRequired, loadTracks: PropTypes.func, renderItem: PropTypes.func } constructor (props) { super(props) // local state stuff // this.state = {} } renderItem (item: trackObject) { return ( <SongItem key={item.id} item={{ avatar_url: item.avatar_url, src: item.src, author: item.author, trackName: item.trackName, playCount: item.playCount }} /> ) } componentDidMount () { this.props.loadTracks('me') } render () { const { isAuthenticated, tracks } = this.props return ( <div> <div> <h2> My tracks </h2> </div> <div> <List selectable> {isAuthenticated && tracks.map(this.renderItem) } </List> </div> <div> <Navigation type='horizontal' theme={classes} onClick={(event, instance) => { } } onTimeout={(event) => { } } > <List> <SongItem item={{ avatar_url: 'testAvatar', src: 'sscc', author: 'synchu', trackName: 'Sample track', playCount: 4, selectable: false }} /> </List> </Navigation> </div> </div> ) } } export default MyTracksView
app/src/Frontend/modules/weui/pages/swiper/index.js
ptphp/ptphp
/** * Created by jf on 15/12/10. */ "use strict"; import React from 'react'; import Page from '../../component/page'; import SwiperBox from "../../../../components/swiper/index"; export default React.createClass({ render() { let slides = [ { url:"#/", pic:"http://7xqzw4.com2.z0.glb.qiniucdn.com/1.jpg" }, { url:"#/", pic:"http://y0.ifengimg.com/haina/2016_17/8717e73c592786b_w588_h307.jpg" } ]; return ( <Page className="swiper" title="Swiper" spacing> <SwiperBox slides={slides}/> </Page> ); } });
examples/CollectionWithHref.js
15lyfromsaturn/react-materialize
import React from 'react'; import Collection from '../src/Collection'; import CollectionItem from '../src/CollectionItem'; export default <Collection> <CollectionItem href='#'>Alvin</CollectionItem> <CollectionItem href='#' active>Alvin</CollectionItem> <CollectionItem href='#'>Alvin</CollectionItem> <CollectionItem href='#'>Alvin</CollectionItem> </Collection>;
src/index.js
huangtingting827/gallery-by-react
import 'core-js/fn/object/assign'; import React from 'react'; import ReactDOM from 'react-dom'; import App from './components/Main'; // Render the main component into the dom ReactDOM.render(<App />, document.getElementById('app'));
app/components/Header/index.js
j921216063/chenya
import React from 'react'; import { FormattedMessage } from 'react-intl'; import Wrapper from './Wrapper'; import NavBar from './NavBar'; import NavItem from './NavItem'; import messages from './messages'; import Title from './Title'; class Header extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { return ( <Wrapper> <Title /> <NavBar> <FormattedMessage {...messages.home} > {(formattedValue) => (<NavItem to="/" index>{formattedValue}</NavItem>)} </FormattedMessage> <NavItem to="/about"> <FormattedMessage {...messages.aboutus} /> </NavItem> <NavItem to="/features"> <FormattedMessage {...messages.features} /> </NavItem> <NavItem to="/business"> <FormattedMessage {...messages.business} /> </NavItem> <NavItem to="/result"> <FormattedMessage {...messages.actualperform} /> </NavItem> <NavItem to="/contact"> <FormattedMessage {...messages.contactus} /> </NavItem> </NavBar> </Wrapper > ); } } export default Header;
src/containers/tool/Doraemon/AlertBar.js
mydearxym/mastani
import React from 'react' import { ICON_CMD } from '@/config' import { Trans } from '@/utils/i18n' import { cutRest } from '@/utils/helper' import { Wrapper, WarningIcon, Info, Title, Desc } from './styles/alert_bar' const AlertBar = ({ value, searchThread }) => ( <Wrapper> <WarningIcon src={`${ICON_CMD}/shell_warning.svg`} /> <Info> <Title> 未找到您需要的 {Trans(searchThread)} &quot; {cutRest(value, 20)} &quot; </Title> <Desc>请尝试其他关键字或查看帮助文档</Desc> </Info> </Wrapper> ) export default AlertBar
src/svg-icons/maps/hotel.js
mit-cml/iot-website-source
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let MapsHotel = (props) => ( <SvgIcon {...props}> <path d="M7 13c1.66 0 3-1.34 3-3S8.66 7 7 7s-3 1.34-3 3 1.34 3 3 3zm12-6h-8v7H3V5H1v15h2v-3h18v3h2v-9c0-2.21-1.79-4-4-4z"/> </SvgIcon> ); MapsHotel = pure(MapsHotel); MapsHotel.displayName = 'MapsHotel'; MapsHotel.muiName = 'SvgIcon'; export default MapsHotel;
src/svg-icons/file/cloud-download.js
matthewoates/material-ui
import React from 'react'; import pure from 'recompose/pure'; import SvgIcon from '../../SvgIcon'; let FileCloudDownload = (props) => ( <SvgIcon {...props}> <path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z"/> </SvgIcon> ); FileCloudDownload = pure(FileCloudDownload); FileCloudDownload.displayName = 'FileCloudDownload'; FileCloudDownload.muiName = 'SvgIcon'; export default FileCloudDownload;
_viewlayers/react/app/app.js
mjanssen/graduation-frontend-setups
import React from 'react'; import { render } from 'react-dom'; import 'style/global'; // Define base component import App from './components/App/App'; // Create init function to render application from function init() { render(<App />, document.querySelector('#root')); } // While developing, enable HMR if (module.hot) { module.hot.accept('./components/App/App', () => { // requestAnimationFrame is used to do one paint within the browser requestAnimationFrame(init); }); } init();
packages/ringcentral-widgets/components/BackButton/index.js
u9520107/ringcentral-js-widget
import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import dynamicsFont from '../../assets/DynamicsFont/DynamicsFont.scss'; import styles from './styles.scss'; export default function BackButton({ label, showIcon, }) { return ( <span className={styles.backButton}> { showIcon ? ( <i className={classnames(dynamicsFont.arrow, styles.backIcon)} /> ) : null } { label ? ( <span className={styles.backLabel}> {label} </span> ) : null } </span> ); } BackButton.propTypes = { label: PropTypes.string, showIcon: PropTypes.bool, }; BackButton.defaultProps = { label: undefined, showIcon: true, };
src/index.js
joakikr/SAAS
import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; import DevTools from './containers/devTools'; import { store } from './store/index'; import { Router, browserHistory } from 'react-router'; import routes from './routes/index'; ReactDOM.render( <Provider store={store}> <div> <Router history={browserHistory} routes={routes} /> <DevTools/> </div> </Provider> , document.querySelector('.container'));
fields/types/html/HtmlField.js
ligson/keystone
import _ from 'underscore'; import Field from '../Field'; import React from 'react'; import tinymce from 'tinymce'; import { FormInput } from 'elemental'; /** * TODO: * - Remove dependency on underscore */ var lastId = 0; function getId() { return 'keystone-html-' + lastId++; } module.exports = Field.create({ displayName: 'HtmlField', getInitialState () { return { id: getId(), isFocused: false }; }, initWysiwyg () { if (!this.props.wysiwyg) return; var self = this; var opts = this.getOptions(); opts.setup = function (editor) { self.editor = editor; editor.on('change', self.valueChanged); editor.on('focus', self.focusChanged.bind(self, true)); editor.on('blur', self.focusChanged.bind(self, false)); }; this._currentValue = this.props.value; tinymce.init(opts); }, componentDidUpdate (prevProps, prevState) { if (prevState.isCollapsed && !this.state.isCollapsed) { this.initWysiwyg(); } if (_.isEqual(this.props.dependsOn, this.props.currentDependencies) && !_.isEqual(this.props.currentDependencies, prevProps.currentDependencies)) { var instance = tinymce.get(prevState.id); if (instance) { tinymce.EditorManager.execCommand('mceRemoveEditor', true, prevState.id); this.initWysiwyg(); } else { this.initWysiwyg(); } } }, componentDidMount () { this.initWysiwyg(); }, componentWillReceiveProps (nextProps) { if (this.editor && this._currentValue !== nextProps.value) { this.editor.setContent(nextProps.value); } }, focusChanged (focused) { this.setState({ isFocused: focused }); }, valueChanged () { var content; if (this.editor) { content = this.editor.getContent(); } else if (this.refs.editor) { content = this.refs.editor.getDOMNode().value; } else { return; } this._currentValue = content; this.props.onChange({ path: this.props.path, value: content }); }, getOptions () { var plugins = ['code', 'link'], options = _.defaults( {}, this.props.wysiwyg, Keystone.wysiwyg.options ), toolbar = options.overrideToolbar ? '' : 'bold italic | alignleft aligncenter alignright | bullist numlist | outdent indent | link', i; if (options.enableImages) { plugins.push('image'); toolbar += ' | image'; } if (options.enableCloudinaryUploads || options.enableS3Uploads) { plugins.push('uploadimage'); toolbar += options.enableImages ? ' uploadimage' : ' | uploadimage'; } if (options.additionalButtons) { var additionalButtons = options.additionalButtons.split(','); for (i = 0; i < additionalButtons.length; i++) { toolbar += (' | ' + additionalButtons[i]); } } if (options.additionalPlugins) { var additionalPlugins = options.additionalPlugins.split(','); for (i = 0; i < additionalPlugins.length; i++) { plugins.push(additionalPlugins[i]); } } if (options.importcss) { plugins.push('importcss'); var importcssOptions = { content_css: options.importcss, importcss_append: true, importcss_merge_classes: true }; _.extend(options.additionalOptions, importcssOptions); } if (!options.overrideToolbar) { toolbar += ' | code'; } var opts = { selector: '#' + this.state.id, toolbar: toolbar, plugins: plugins, menubar: options.menubar || false, skin: options.skin || 'keystone' }; if (this.shouldRenderField()) { opts.uploadimage_form_url = options.enableS3Uploads ? '/keystone/api/s3/upload' : '/keystone/api/cloudinary/upload'; } else { _.extend(opts, { mode: 'textareas', readonly: true, menubar: false, toolbar: 'code', statusbar: false }); } if (options.additionalOptions){ _.extend(opts, options.additionalOptions); } return opts; }, getFieldClassName () { var className = this.props.wysiwyg ? 'wysiwyg' : 'code'; return className; }, renderField () { var className = this.state.isFocused ? 'is-focused' : ''; var style = { height: this.props.height }; return ( <div className={className}> <FormInput multiline ref='editor' style={style} onChange={this.valueChanged} id={this.state.id} className={this.getFieldClassName()} name={this.props.path} value={this.props.value} /> </div> ); }, renderValue () { return <FormInput multiline noedit value={this.props.value} />; } });
src/parts/section-card-link.js
economist-components/component-sections-card
import React from 'react'; import PropTypes from 'prop-types'; import Button from '@economist/component-link-button'; export default function SectionCardLink({ buttonClassName, linkClassName, title, buttonProps, prefix }) { const customLinkClassName = linkClassName ? `${ prefix }__list-item ${ prefix }__list-item--${ linkClassName }` : `${ prefix }__list-item`; return ( <li className={customLinkClassName}> <Button {...buttonProps} className={buttonClassName} > {title} </Button> </li> ); } if (process.env.NODE_ENV !== 'production') { SectionCardLink.propTypes = { buttonClassName: PropTypes.string, linkClassName: PropTypes.string, buttonProps: PropTypes.shape({ target: PropTypes.string, unstyled: PropTypes.bool, href: PropTypes.string, title: PropTypes.string, }), title: PropTypes.oneOfType([ PropTypes.string, PropTypes.element, ]), prefix: PropTypes.string, }; }
docs/client.js
nickuraltsev/react-bootstrap
import 'bootstrap/less/bootstrap.less'; import './assets/docs.css'; import './assets/style.css'; import './assets/carousel.png'; import './assets/logo.png'; import './assets/favicon.ico'; import './assets/thumbnail.png'; import './assets/thumbnaildiv.png'; import 'codemirror/mode/htmlmixed/htmlmixed'; import 'codemirror/mode/javascript/javascript'; import 'codemirror/theme/solarized.css'; import 'codemirror/lib/codemirror.css'; import './assets/CodeMirror.css'; import React from 'react'; import CodeMirror from 'codemirror'; import 'codemirror/addon/runmode/runmode'; import Router from 'react-router'; import routes from './src/Routes'; global.CodeMirror = CodeMirror; Router.run(routes, Router.RefreshLocation, Handler => { React.render( React.createElement(Handler, window.INITIAL_PROPS), document); });
docs/src/CodeExample.js
xuorig/react-bootstrap
import React from 'react'; export default class CodeExample extends React.Component { render() { return ( <pre className="cm-s-solarized cm-s-light"> <code> {this.props.codeText} </code> </pre> ); } componentDidMount() { if (CodeMirror === undefined) { return; } CodeMirror.runMode( this.props.codeText, this.props.mode, React.findDOMNode(this).children[0] ); } }
docs/app/Examples/views/Statistic/Types/StatisticExampleBottomLabel.js
clemensw/stardust
import React from 'react' import { Statistic } from 'semantic-ui-react' const StatisticExampleBottomLabel = () => ( <div> <Statistic> <Statistic.Value>5,550</Statistic.Value> <Statistic.Label>Downloads</Statistic.Label> </Statistic> <Statistic value='5,500' label='Downloads' /> </div> ) export default StatisticExampleBottomLabel
src/views/info/data/chart.js
rekyyang/ArtificalLiverCloud
/** * Created by reky on 2016/11/9. */ import React from 'react'; import ReactEcharts from 'echarts-for-react'; import {Slider} from 'antd'; export default class Chart extends React.Component{ /*propTypes = { yAxisName: React.PropTypes.string.isRequired, };*/ getInitialOption = function (){ return ( this.defaultOption ) }; getOption = function (){ return ( this.option ) }; defaultOption1 = { tooltip : { trigger: 'item' }, legend: { data: ['Growth', 'Budget 2011', 'Budget 2012'], itemGap: 5 }, grid: { top: '12%', left: '1%', right: '10%', containLabel: true }, xAxis: [ { type : 'category', //data : obama_budget_2012.names } ], yAxis: [ { type : 'value', name : 'Budget (million USD)', } ], dataZoom: [ { type: 'slider', show: true, start: 94, end: 100, handleSize: 8 }, { type: 'inside', start: 94, end: 100 }, { type: 'slider', show: true, yAxisIndex: 0, filterMode: 'empty', width: 12, height: '70%', handleSize: 8, showDataShadow: false, left: '93%' } ], series : [ { name: 'Budget 2011', type: 'bar', //data: obama_budget_2012.budget2011List }, { name: 'Budget 2012', type: 'bar', //data: obama_budget_2012.budget2012List } ] }; /* 需要作为标签引出的 标题 title.text string X轴数据 xAxis.data array 分段颜色 visualMap y轴数据 series.data */ /*需要添加的功能 toolbox dataZoom */ defaultOption = { dataZoom: [ { id: 'dataZoomX', type: 'slider', xAxisIndex: [0], filterMode: 'filter' }, { id: 'dataZoomY', type: 'slider', yAxisIndex: [0], filterMode: 'empty' }], title : { show: true, }, legend : { show: true, }, grid : { show: true, }, xAxis : { inverse: "true", data : [{ value: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18, 'y=x'], }], }, yAxis : { type: "value", }, series : { type : 'line', name : 'Pressure', data : [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18], }, toolbox: { left: 'center', feature: { dataZoom: { yAxisIndex: 'none' }, restore: {}, saveAsImage: {} } }, visualMap: { pieces: [{ gt: 0, lte: 6, color: '#ff6100' },{ gt: 5, lte: 12, color: '#66ccff' },{ gt: 12, lte: 20, color: '#ff6100' }], } }; render() { this.option = this.getInitialOption(); return ( <div> <ReactEcharts option={this.getOption()} height={150} width ={300} /> </div> ) } }
app/components/form/index.js
Vizzuality/forest-watcher
// @flow import type { Question, Answer } from 'types/reports.types'; import React, { Component } from 'react'; import i18n from 'i18next'; import { Platform, View } from 'react-native'; import debounceUI from 'helpers/debounceUI'; import { trackScreenView, trackReportingConcluded } from 'helpers/analytics'; import styles from 'components/form/styles'; import ActionButton from 'components/common/action-button'; import FormField from 'components/common/form-inputs'; import NextButton from 'components/form/next-button'; import withDraft from 'components/form/withDraft'; import { Navigation } from 'react-native-navigation'; type Props = { question: Question, questionAnswered: boolean, updateOnly: boolean, reportName: string, nextQuestionIndex: ?number, answer: Answer, text: string, setReportAnswer: (string, Answer, boolean) => void, componentId: string, editMode: boolean, /** * The component Id to pop to if in edit mode */ popToComponentId: string }; const closeIcon = require('assets/close.png'); class Form extends Component<Props> { static options(passProps) { return { topBar: { title: { text: i18n.t('report.title') }, leftButtons: passProps.editMode ? [] : [ { id: 'backButton', text: i18n.t('commonText.cancel'), icon: Platform.select({ android: closeIcon }) } ] } }; } componentDidMount() { trackScreenView('Reporting - Form Step'); } /** * navigationButtonPressed - Handles events from the back button on the modal nav bar. * * @param {type} { buttonId } The component ID for the button. */ navigationButtonPressed({ buttonId }) { if (buttonId === 'backButton') { if (this.props.nextQuestionIndex !== null || !this.props.editMode) { trackReportingConcluded('cancelled', 'answers'); Navigation.dismissModal(this.props.componentId); } else { Navigation.popToRoot(this.props.componentId); } } } shouldComponentUpdate(nextProps) { return this.props.answer !== nextProps.answer; } onChange = answer => { const { setReportAnswer, reportName, updateOnly } = this.props; setReportAnswer(reportName, answer, updateOnly); }); onSubmit = debounceUI(() => { const { componentId, reportName, nextQuestionIndex, answer, setReportAnswer, updateOnly, editMode, questionAnswered, popToComponentId } = this.props; if (!questionAnswered) { setReportAnswer(reportName, answer, updateOnly); } if (editMode) { Navigation.popTo(popToComponentId); } else if (nextQuestionIndex !== null) { Navigation.push(componentId, { component: { name: 'ForestWatcher.NewReport', passProps: { editMode, reportName, questionIndex: nextQuestionIndex } } }); } else { Navigation.push(componentId, { component: { name: 'ForestWatcher.Answers', passProps: { reportName } } }); } }); getNext(question, questionAnswered, text) { const disabled = question.required && !questionAnswered; const isBlob = question && question.type === 'blob'; const Next = isBlob ? NextButton : ActionButton; const style = isBlob ? styles.buttonNextPos : styles.buttonPos; return <Next style={style} disabled={disabled} onPress={this.onSubmit} text={!isBlob && text} />; } render() { const { question, answer, reportName, questionAnswered, text } = this.props; return ( <View style={styles.container}> {question && <FormField reportName={reportName} question={question} answer={answer} onChange={this.onChange} />} {this.getNext(question, questionAnswered, text)} </View> ); } } export default withDraft(Form);
src/js/components/icons/base/Aid.js
linde12/grommet
// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import CSSClassnames from '../../../utils/CSSClassnames'; import Intl from '../../../utils/Intl'; import Props from '../../../utils/Props'; const CLASS_ROOT = CSSClassnames.CONTROL_ICON; const COLOR_INDEX = CSSClassnames.COLOR_INDEX; export default class Icon extends Component { render () { const { className, colorIndex } = this.props; let { a11yTitle, size, responsive } = this.props; let { intl } = this.context; const classes = classnames( CLASS_ROOT, `${CLASS_ROOT}-aid`, className, { [`${CLASS_ROOT}--${size}`]: size, [`${CLASS_ROOT}--responsive`]: responsive, [`${COLOR_INDEX}-${colorIndex}`]: colorIndex } ); a11yTitle = a11yTitle || Intl.getMessage(intl, 'aid'); const restProps = Props.omit(this.props, Object.keys(Icon.propTypes)); return <svg {...restProps} version="1.1" viewBox="0 0 24 24" width="24px" height="24px" role="img" className={classes} aria-label={a11yTitle}><path fill="none" stroke="#000" strokeWidth="2" d="M1,22 L23,22 L23,6 L1,6 L1,22 Z M8,6 L16,6 L16,2 L8,2 L8,6 Z M8,14 L16,14 M12,10 L12,18"/></svg>; } }; Icon.contextTypes = { intl: PropTypes.object }; Icon.defaultProps = { responsive: true }; Icon.displayName = 'Aid'; Icon.icon = true; Icon.propTypes = { a11yTitle: PropTypes.string, colorIndex: PropTypes.string, size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'huge']), responsive: PropTypes.bool };
web/assets/js/buypage/Buy.js
xuqiantong/NY_Auto
/* Buy Page Author: ML2436 */ import React, { Component } from 'react'; import './Buy.css'; var Grid = require('react-bootstrap/lib/Grid'); var Row = require('react-bootstrap/lib/Row'); var Col = require('react-bootstrap/lib/Col'); var Form = require('react-bootstrap/lib/Form'); var FormGroup = require('react-bootstrap/lib/FormGroup'); var FormControl = require('react-bootstrap/lib/FormControl'); var ControlLabel = require('react-bootstrap/lib/ControlLabel'); var Button = require('react-bootstrap/lib/Button'); var Checkbox = require('react-bootstrap/lib/Checkbox'); var ButtonToolbar = require('react-bootstrap/lib/ButtonToolbar'); var ButtonGroup = require('react-bootstrap/lib/ButtonGroup'); var Image = require('react-bootstrap/lib/Image'); var Panel = require('react-bootstrap/lib/Panel'); const CARS = [ { id: 0, name: { year: 2015, make: 'BMW', model: '430i', trim:'xDrive' }, mileage:20000, price: 29990, stocked: true, color: { extColor:'red', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/1.jpg' }, { id: 1, name: { year: 2014, make: 'BMW', model: '430i', trim:'xDrive' }, mileage:28000, price: 29990, stocked: true, color: { extColor:'red', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/2.jpg' }, { id: 2, name: { year: 2013, make: 'BMW', model: '430i', trim:'xDrive' }, mileage:37000, price: 29990, stocked: true, color: { extColor:'blue', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/3.jpg' }, { id: 3, name: { year: 2015, make: 'BMW', model: '335i', trim:'xDrive' }, mileage:20000, price: 29990, stocked: true, color: { extColor:'black', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/4.jpg' }, { id: 4, name: { year: 2014, make: 'BMW', model: '335i', trim:'' }, mileage:28000, price: 29990, stocked: true, color: { extColor:'yellow', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/5.jpg' }, { id: 5, name: { year: 2013, make: 'BMW', model: '335i', trim:'xDrive' }, mileage:37000, price: 29990, stocked: true, color: { extColor:'yellow', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/6.jpg' }, { id: 6, name: { year: 2015, make: 'Toyota', model: 'Camry', trim:'LE' }, mileage:20000, price: 29990, stocked: true, color: { extColor:'yellow', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/7.jpg' }, { id: 7, name: { year: 2014, make: 'Toyota', model: 'Camry', trim:'SE' }, mileage:28000, price: 29990, stocked: true, color: { extColor:'yellow', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/8.jpg' }, { id: 8, name: { year: 2013, make: 'Toyota', model: 'Camry', trim:'XLE' }, mileage:37000, price: 29990, stocked: true, color: { extColor:'yellow', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/1.jpg' }, { id: 9, name: { year: 2015, make: 'Honda', model: 'Accord', trim:'LX' }, mileage:20000, price: 29990, stocked: true, color: { extColor:'yellow', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/2.jpg' }, { id: 10, name: { year: 2006, make: 'Honda', model: 'S2000', trim:'' }, mileage:70000, price: 29990, stocked: true, color: { extColor:'yellow', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/3.jpg' }, { id: 11, name: { year: 2016, make: 'Mazda', model: 'Miata', trim:'Club' }, mileage:20000, price: 29990, stocked: true, color: { extColor:'yellow', intColor:'black' }, equips: ['Heating seats', 'Navigation', 'Backup camera', 'Double-clutch Trans', 'Parking sensor', 'Red leather'], imgpath: './static/bundles/images/4.jpg' } ]; // Filter function BuyFilter(props){ return ( <Col xs={4} sm={3} md={2} className="buy-filter"> <Form horizontal> <BuyFilterHeader /> <BuyFilterBody /> </Form> </Col> ); } function BuyFilterHeader(props){ return ( <FormGroup className="buy-filter-header"> <Col xs={4} sm={6} md={8} className="buy-filter-header-word"> Filter </Col> <Col xs={8} sm={6} md={4}> <FilterButton /> </Col> </FormGroup> ); } function FilterButton(props){ return ( <Button bsStyle="info" type="reset" bsSize="xs" className="buy-filter-header-button">Reset</Button> ); } function BuyFilterBody(props){ var bodystyles = ['Sedan','Coupe','SUV','Hatchback','minivan','Wagon','Truck','Convertible']; var trans = ['Automatic','Manual']; var colors = ['#000000', '#a9a9aa', '#ffffff', '#ea0a26', '#e0790a', '#fcd206', '#c9a611', '#117204', '#0665c4', '#7e18c6', '#ed3e7d', '#990a0a', '#683c02', '#b7926e', '#666666']; return ( <FormGroup className="buy-filter-body"> <FBPopularHits /> <FBMake /> <FBSlider title="Miles" minlabel="New" maxlabel="No limit"/> <FBSlider title="Year" minlabel="Past" maxlabel="Now"/> <FBCheckBox title="Body Style" boxes={bodystyles}/> <FBCheckBox title="Transmission" boxes={trans}/> <FBColor title="Exterior Color" colors={colors}/> <FBColor title="Interior Color" colors={colors}/> </FormGroup> ); } function FBPopularHits(props){ var hits = ['Benz C300', 'BMW 320i', 'GHibi']; const displayhits = hits.map( (hit) => <Button bsSize="xs" className="buy-filter-hits-button">{hit}</Button> ); return ( <Col xs={12} sm={12} md={12}> <FormGroup className="buy-filter-container"> <Col xs={12} sm={12} md={12} className="buy-filter-title"><ControlLabel>Popular Hits</ControlLabel></Col> <Col xs={12} sm={12} md={12} className="buy-filter-color"> <ButtonToolbar> <ButtonGroup> {displayhits} </ButtonGroup> </ButtonToolbar> </Col> </FormGroup> </Col> ); } function FBMake(props){ var makes = ['Benz', 'Toyota', 'Honda', 'BMW', 'Meserati']; const displaymakes = makes.map( (make) => <Button bsSize="xs" className="buy-filter-makes-button">{make}</Button> ); return ( <Col xs={12} sm={12} md={12}> <FormGroup className="buy-filter-container"> <Col xs={12} sm={12} md={12} className="buy-filter-title"><ControlLabel>Make</ControlLabel></Col> <Col xs={12} sm={12} md={12} className="buy-filter-color"> <FormControl bsSize="sm" type="text" placeholder="Quick Search" /> </Col> <Col xs={12} sm={12} md={12} className="buy-filter-color"> <ButtonToolbar> <ButtonGroup> {displaymakes} </ButtonGroup> </ButtonToolbar> </Col> </FormGroup> </Col> ); } function FBSlider(props){ return ( <Col xs={12} sm={12} md={12}> <FormGroup className="buy-filter-container"> <Col xs={12} sm={12} md={12} className="buy-filter-title"><ControlLabel>{props.title}</ControlLabel></Col> <Col xs={12} sm={12} md={12} className="buy-filter-slider"> <input type="range" min={props.minlabel} max={props.maxlabel} /> </Col> </FormGroup> </Col> ); } function FBCheckBox(props){ const displaybox = props.boxes.map( (box) => <Col xs={11} sm={11} md={5}><Checkbox inline name={box}>{box}</Checkbox></Col> ); return ( <Col xs={12} sm={12} md={12}> <FormGroup className="buy-filter-container"> <Col xs={12} sm={12} md={12}><ControlLabel>{props.title}</ControlLabel></Col> {displaybox} </FormGroup> </Col> ); } function FBColor(props){ const displaycolor = props.colors.map( (color) => <Col xs={6} sm={4} md={3} className="buy-filter-color"><Button bsSize="xs" bsClass="buy-filter-col" style={{backgroundColor:color}}>&nbsp;</Button></Col> ); return ( <Col xs={12} sm={12} md={12}> <FormGroup className="buy-filter-container"> <Col xs={12} sm={12} md={12} className="buy-filter-title"><ControlLabel>{props.title}</ControlLabel></Col> <Row> <Col xs={11} sm={11} md={11}> <Col xs={6} sm={4} md={3} className="buy-filter-color"><Button bsSize="xs" bsClass="buy-filter-col" style={{backgroundColor:0xFFFFFF}}>ALL</Button></Col> {displaycolor} </Col> </Row> </FormGroup> </Col> ); } // Car list function CarList(props){ var cars = []; for (var $i = 0; $i < 12; $i++){ cars.push(CARS[$i]); } const displaycars = cars.map( (car) => <Col xs={10} sm={6} md={4} key={car.id} className="buy-carlist-car"> <Car car={car}/> </Col> ); return ( <Col xs={8} sm={9} md={10} className="buy-carlist"> {displaycars} <LoadMore /> </Col> ); } function Car(props) { const car = props.car; const bgImage = car.imgpath; const itemStyle = { backgroundImage: "url(" + bgImage + ")", backgroundSize: "cover", backgroundPositionY: "50%", backgroundPositionX: "50%" }; return ( <Col className="buy-car"> <div className="buy-car-image-wrapper" style={itemStyle}></div> <Panel className="buy-car-panel"> <Col xs={9} sm={10} md={10} className="car-attribute"> {car.name.year} {car.name.make} {car.name.model} {car.name.trim} </Col> <Col xs={9} sm={10} md={10} className="car-attribute"> {car.mileage} miles </Col> <Col xs={9} sm={10} md={10} className="car-attribute"> $ {car.price} </Col> </Panel> </Col> ); } function LoadMore(props) { return ( <Row className="loadmore"> <Col xs={12} sm={12} md={12}> <Button bsSize="large" block> Load More </Button> </Col> </Row> ); } export default class Buy extends Component { render(){ return ( <Grid className="buy-page"> <Row> <BuyFilter /> <CarList /> </Row> </Grid> ); } }
src/PriceList.js
weizong85/coffee-test-code
import React from 'react'; class PriceList extends React.Component { addToOrderList() { this.props.addToOrderList(this) } render() { return ( <li> <div> {this.props.price.size} ${this.props.price.cost} <input type="button" onClick={this.addToOrderList.bind(this)} value='Add' /> </div> </li> ) } } export default PriceList;
stories/react/Input.stories.js
onap-sdc/sdc-ui
import React from 'react'; import { action } from '@storybook/addon-actions'; import Examples from './utils/Examples.js'; import ReactInput from '../../src/react/Input.js'; import InputDefaultHtml from '../../components/input/input.html'; import InputRequiredHtml from '../../components/input/input-required.html'; import InputNumberHtml from '../../components/input/input-number.html'; import InputViewOnlyHtml from '../../components/input/input-view-only.html'; import InputDisabledHtml from '../../components/input/input-disabled.html'; import InputPlaceholderHtml from '../../components/input/input-placeholder.html'; import InputErrorHtml from '../../components/input/input-error.html'; let examples = { 'Input Default': { jsx: <ReactInput name='input1' value='Default' label='I am a label' onChange={ action('input-change')}/>, html: InputDefaultHtml }, 'Input Required': { jsx: <ReactInput name='input2' value='Default' label='I am a label' onChange={ action('input-change')} isRequired/>, html: InputRequiredHtml }, 'Input Number': { jsx: <ReactInput name='input3' value='3' label='I am a label' type="number" onChange={ action('input-change')}/>, html: InputNumberHtml }, 'Input View Only': { jsx: <ReactInput value='Read Only Text' label='I am a label' onChange={ action('input-change')} readOnly/>, html: InputViewOnlyHtml }, 'Input Disabled': { jsx: <ReactInput value='Default' label='I am a label' onChange={ action('input-change')} disabled/>, html: InputDisabledHtml }, 'Input Placeholder': { jsx: <ReactInput name='input5' placeholder='Write Here...' label='I am a label' onChange={ action('input-change')}/>, html: InputPlaceholderHtml }, 'Input Error': { jsx: <ReactInput value='Default' name='input6' label='I am a label' errorMessage='This is the error message' onChange={ action('input-change')}/>, html: InputErrorHtml } } const Inputs = () => ( <Examples examples={examples} /> ); export default Inputs;
src/utils/devTools.js
Lukkub/Redux-ShopCartApp
import React from 'react'; import { createStore as initialCreateStore, compose } from 'redux'; export let createStore = initialCreateStore; let __DEV__ = false; if (__DEV__) { createStore = compose( require('redux-devtools').devTools(), require('redux-devtools').persistState( window.location.href.match(/[?&]debug_session=([^&]+)\b/) ), createStore ); } export function renderDevTools(store) { if (__DEV__) { let {DevTools, DebugPanel, LogMonitor} = require('redux-devtools/lib/react'); return ( <DebugPanel top right bottom> <DevTools store={store} monitor={LogMonitor} /> </DebugPanel> ); } return null; }
src/shared/form/RadioList.js
AusDTO/dto-digitalmarketplace-frontend
import React from 'react'; import PropTypes from 'prop-types' import { Control } from 'react-redux-form'; import StatefulError from './StatefulError'; const RadioList = (props) => { const { id, label, name, options, model, messages, validators } = props; return ( <div className="field"> <fieldset> <legend>{label}</legend> <StatefulError model={model} messages={messages} id={id} /> <div> {options.map((option, i) => { let fieldId = `${id}-${option.value}`; return ( <span key={i}> <Control.radio model={model} name={name} id={fieldId} value={option.value} validators={validators} /> <label htmlFor={fieldId}>{option.label}</label> </span> ) })} </div> </fieldset> </div> ); }; RadioList.propTypes = { id: PropTypes.string.isRequired, label: PropTypes.string.isRequired, name: PropTypes.string.isRequired, model: PropTypes.oneOfType([ PropTypes.func, PropTypes.string, ]).isRequired, options: PropTypes.arrayOf(PropTypes.shape({ label: PropTypes.oneOfType([ PropTypes.string, PropTypes.object ]), value: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]) })).isRequired, validators: PropTypes.object, messages: PropTypes.object, }; export default RadioList;
src/html.js
jumpalottahigh/jumpalottahigh.github.io
import React from 'react' import PropTypes from 'prop-types' export default class HTML extends React.Component { render() { return ( <html {...this.props.htmlAttributes} lang="en"> <head> <meta charSet="utf-8" /> <meta httpEquiv="x-ua-compatible" content="ie=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> {this.props.headComponents} </head> <body {...this.props.bodyAttributes}> {this.props.preBodyComponents} <div key={`body`} id="___gatsby" dangerouslySetInnerHTML={{ __html: this.props.body }} /> {this.props.postBodyComponents} </body> </html> ) } } HTML.propTypes = { htmlAttributes: PropTypes.object, headComponents: PropTypes.array, bodyAttributes: PropTypes.object, preBodyComponents: PropTypes.array, body: PropTypes.string, postBodyComponents: PropTypes.array, }
test/index.android.js
ivanl001/ReactNative-Learning
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from 'react-native'; export default class test extends Component { render() { return ( <View style={styles.container}> <Text style={styles.welcome}> Welcome to React Native! </Text> <Text style={styles.instructions}> To get started, edit index.android.js </Text> <Text style={styles.instructions}> Double tap R on your keyboard to reload,{'\n'} Shake or press menu button for dev menu </Text> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, }); AppRegistry.registerComponent('test', () => test);
packages/material-ui-icons/src/ViewDay.js
cherniavskii/material-ui
import React from 'react'; import createSvgIcon from './utils/createSvgIcon'; export default createSvgIcon( <g><path d="M2 21h19v-3H2v3zM20 8H3c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h17c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zM2 3v3h19V3H2z" /></g> , 'ViewDay');
frontend/src/app/cmdb/group/edit.js
the-invoice/nab
import React, { Component } from 'react'; import { Link } from 'react-router'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import { pushPath } from 'redux-simple-router'; import { Route, IndexRoute } from 'react-router'; import { createSelector } from 'reselect'; import * as cmdbSelectors from 'app/cmdb/selectors'; import * as selectors from './selectors'; import * as actions from 'app/cmdb/actions'; import { View } from 'ui/layout'; import { GroupEditForm } from './edit-form'; function mapActionsToProps(dispatch) { return { actions: bindActionCreators(actions, dispatch), }; } const createModeSelector = (state, props) => props.route.createMode; const selector = createSelector( selectors.groupIdFromParams, selectors.currentGroup, cmdbSelectors.groupTypesList, createModeSelector, (group_id, group, groupTypesList, createMode) => { return { group_id, group, groupTypesList, createMode, } } ); @connect(selector, mapActionsToProps) export class GroupEdit extends Component { constructor(props) { super(props); this.state = {isSaving: false, msg: ''}; } componentDidMount() { const { groupTypesList, actions: { loadGroupTypes } } = this.props; if (!groupTypesList.length) { loadGroupTypes(); } } handleSubmitSave(formData) { const { group, actions: { saveItem, loadGroups } } = this.props; const item = { ...group, ...formData, }; this.setState({isSaving: true}); saveItem(item) .then(result => { this.setState({isSaving: false}); loadGroups([group.group_id,]); }) .catch((e) => { console.log(e); this.setState({isSaving: false}); }) } handleSubmitCreate(formData) { const { group, actions: { saveItem, loadGroupChildren } } = this.props; const parent_id = group && group.group_id; const item = { ...formData, type: 'group', parent_id, }; this.setState({isSaving: true}); saveItem(item) .then(result => { this.setState({isSaving: false}); loadGroupChildren(parent_id); }) .catch((e) => { console.log(e); this.setState({isSaving: false}); }) } render() { const { group, groupTypesList, groupTypes, createMode } = this.props; const { isSaving, msg } = this.state; return ( <div> <div> {isSaving ? 'Saving...' : (createMode ? 'Create new group' : 'Edit group')} </div> <GroupEditForm onSave={createMode ? this.handleSubmitCreate.bind(this) : this.handleSubmitSave.bind(this)} btnLabel={createMode ? 'Create' : 'Save'} initialValues={createMode ? {group_type_id: 1, name: ''} : group} groupTypesList={groupTypesList} /> </div> ); } }
src/interface/others/PlayerBreakdown.js
ronaldpereira/WoWAnalyzer
import React from 'react'; import PropTypes from 'prop-types'; import { Trans } from '@lingui/macro'; import SPECS from 'game/SPECS'; import SpecIcon from 'common/SpecIcon'; import { formatNumber } from 'common/format'; import { TooltipElement } from 'common/Tooltip'; import indexByProperty from 'common/indexByProperty'; import Toggle from 'react-toggle'; import SpellLink from 'common/SpellLink'; import PerformanceBar from 'interface/PerformanceBar'; class PlayerBreakdown extends React.Component { static propTypes = { report: PropTypes.object.isRequired, spellreport: PropTypes.object, players: PropTypes.array.isRequired, }; state = { showPlayers: true, }; calculatePlayerBreakdown(statsByTargetId, players) { const friendlyStats = []; const playersById = indexByProperty(players, 'id'); Object.keys(statsByTargetId) .forEach(targetId => { const playerStats = statsByTargetId[targetId]; const playerInfo = playersById[targetId]; if (playerInfo) { friendlyStats.push({ ...playerInfo, ...playerStats, masteryEffectiveness: playerStats.healingFromMastery / (playerStats.maxPotentialHealingFromMastery || 1), }); } }); return friendlyStats; } calculateSpellBreakdown(statsBySpellId) { const spellStats = []; Object.keys(statsBySpellId) .forEach(spellId => { const spell = statsBySpellId[spellId]; spellStats.push({ ...spell, masteryEffectiveness: spell.healingFromMastery / (spell.maxPotentialHealingFromMastery || 1), }); }); return spellStats; } render() { const { report, spellreport, players } = this.props; const friendlyStats = this.calculatePlayerBreakdown(report, players); const totalEffectiveHealing = Object.values(report).reduce((sum, player) => sum + player.effectiveHealing, 0); const highestEffectiveHealing = friendlyStats.reduce((highest, player) => Math.max(highest, player.effectiveHealing), 1); const highestMasteryEffectiveness = friendlyStats.reduce((highest, player) => Math.max(highest, player.masteryEffectiveness), 0); let spellStats = []; let totalSpellEffectiveHealing = 0; let highestSpellEffectiveHealing = 0; let highestSpellMasteryEffectiveness = 0; if (spellreport) { spellStats = this.calculateSpellBreakdown(spellreport); totalSpellEffectiveHealing = Object.values(spellreport).reduce((sum, spell) => sum + spell.effectiveHealing, 0); highestSpellEffectiveHealing = spellStats.reduce((highest, spell) => Math.max(highest, spell.effectiveHealing), 1); highestSpellMasteryEffectiveness = spellStats.reduce((highest, spell) => Math.max(highest, spell.masteryEffectiveness), 0); } return ( <> {spellreport && <div className="pad"> <div className="pull-right"> <div className="toggle-control pull-left" style={{ marginLeft: '.5em' }}> <label htmlFor="healing-toggle" style={{ marginLeft: '0.5em', marginRight: '1em' }}> Spells </label> <Toggle defaultChecked icons={false} onChange={event => this.setState({ showPlayers: event.target.checked })} id="healing-toggle" /> <label htmlFor="healing-toggle" style={{ marginLeft: '0.5em' }}> Players </label> </div> </div> </div> } <table className="data-table"> <thead> <tr style={{ textTransform: 'uppercase' }}> <th><Trans>Name</Trans></th> <th colSpan="2"><Trans>Mastery effectiveness</Trans></th> <th colSpan="3"><TooltipElement content={<Trans>This is the amount of healing done by spells affected by mastery. Things like Holy Paladin beacons or Restoration Shaman feeding are NOT included.</Trans>}><Trans>Healing done</Trans></TooltipElement></th> </tr> </thead> <tbody> {!this.state.showPlayers && spellStats && spellStats .sort((a, b) => b.masteryEffectiveness - a.masteryEffectiveness) .map((spell) => { // We want the performance bar to show a full bar for whatever healing done percentage is highest to make // it easier to see relative amounts. const performanceBarMasteryEffectiveness = spell.masteryEffectiveness / highestSpellMasteryEffectiveness; const performanceBarHealingDonePercentage = spell.effectiveHealing / highestSpellEffectiveHealing; const actualHealingDonePercentage = spell.effectiveHealing / totalSpellEffectiveHealing; return ( <tr key={spell.spellId}> <td style={{ width: '20%' }}> <SpellLink id={spell.spellId} /> </td> <td style={{ width: 50, textAlign: 'right' }}> {(Math.round(spell.masteryEffectiveness * 10000) / 100).toFixed(2)}% </td> <td style={{ width: '40%' }}> <PerformanceBar percent={performanceBarMasteryEffectiveness} /> </td> <td style={{ width: 50, textAlign: 'right' }}> {(Math.round(actualHealingDonePercentage * 10000) / 100).toFixed(2)}% </td> <td style={{ width: '40%' }}> <PerformanceBar percent={performanceBarHealingDonePercentage} /> </td> <td style={{ width: 50, textAlign: 'right' }}> {(formatNumber(spell.effectiveHealing))} </td> </tr> ); })} {this.state.showPlayers && friendlyStats && friendlyStats .sort((a, b) => b.masteryEffectiveness - a.masteryEffectiveness) .map((player) => { const combatant = player.combatant; if (!combatant) { console.error('Missing combatant:', player); return null; // pet or something } const spec = SPECS[combatant.specId]; const specClassName = spec.className.replace(' ', ''); // We want the performance bar to show a full bar for whatever healing done percentage is highest to make // it easier to see relative amounts. const performanceBarMasteryEffectiveness = player.masteryEffectiveness / highestMasteryEffectiveness; const performanceBarHealingReceivedPercentage = player.effectiveHealing / highestEffectiveHealing; const actualHealingReceivedPercentage = player.effectiveHealing / totalEffectiveHealing; return ( <tr key={combatant.id}> <td style={{ width: '20%' }}> <SpecIcon id={spec.id} />{' '} {combatant.name} </td> <td style={{ width: 50, textAlign: 'right' }}> {(Math.round(player.masteryEffectiveness * 10000) / 100).toFixed(2)}% </td> <td style={{ width: '40%' }}> <div className="flex performance-bar-container"> <div className={`flex-sub performance-bar ${specClassName}-bg`} style={{ width: `${performanceBarMasteryEffectiveness * 100}%` }} /> </div> </td> <td style={{ width: 50, textAlign: 'right' }}> {(Math.round(actualHealingReceivedPercentage * 10000) / 100).toFixed(2)}% </td> <td style={{ width: '40%' }}> <div className="flex performance-bar-container"> <div className={`flex-sub performance-bar ${specClassName}-bg`} style={{ width: `${performanceBarHealingReceivedPercentage * 100}%` }} /> </div> </td> <td style={{ width: 50, textAlign: 'right' }}> {(formatNumber(player.effectiveHealing))} </td> </tr> ); })} </tbody> </table> </> ); } } export default PlayerBreakdown;
src/admin/app/index.js
jgretz/node-bits-admin
import './styles/styles.scss'; import 'react-select/dist/react-select.css'; import 'react-virtualized/styles.css'; import './babelHelpers'; import 'core-js/es6/symbol'; import 'core-js/es6/promise'; import 'core-js/es6/array'; import 'core-js/es6/number'; import 'core-js/es6/object'; import React from 'react'; import {Provider} from 'react-redux'; import {browserHistory, Router} from 'react-router'; import {render} from 'react-dom'; import {syncHistoryWithStore} from 'react-router-redux'; import {configureHttp, configureToastr} from './util'; import configureStore from './store/configureStore'; import routes from './routes'; // configure stuff const store = configureStore(); configureHttp(store); configureToastr(); const history = syncHistoryWithStore(browserHistory, store); // render render( <Provider store={store}> <Router history={history} routes={routes} /> </Provider>, document.getElementById('app') );