cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

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

Auto-Updating Preview

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

            
              .FittingRoom {
  font-family: Helvetica;
  text-align: center;
  background-color: #ffffff;
  width: 150px;
  color: #111111;
  margin: 4px;
  border: 1px solid #aaaaaa;
  border-top: 0 solid #aaaaaa;
  position: relative;

  &__Container {
    padding: 16px 16px 24px 16px;
  }

  &__Label {
    margin: 0 auto;
    font-size: 24px;
    padding: 4px;
    text-align: center;
    height: 32px;
    width: 32px;
    border-radius: 9999px;
    background-color: #aaaaaa;
    color: white;
  }

  &__Status {
    margin-top: 8px;
    padding: 8px 0;
    font-size: 18px;
  }

  &__Timer {
    padding: 8px 0;
    font-size: 16px;
  }
}

.FittingRoom--Open {
  color: #66A97A;
  .FittingRoom__Container {
    border-top: 8px solid #66A97A;
  }
  .FittingRoom__StatusBar {
    background-color: #66A97A;
  }
  .FittingRoom__Label {
    background-color: #66A97A;
  }
}

.FittingRoom--Occupied {
  .FittingRoom__Container {
    border-top: 8px solid #ff0000;
  }
  .FittingRoom__Label {
    background-color: #ff0000;
  }
}

.FittingRoom--Closed {
  color: #aaaaaa;
  .FittingRoom__Container {
    border-top: 8px solid #aaaaaa;
  }
  .FittingRoom__Label {
    background-color: #aaaaaa;
  }
}

.FittingRoomActionsMenu {
  position: absolute;
  top: 80%;
  left: 0;
  height: auto;
  z-index: 3;

  &__Arrow {
    position: absolute;
    top: -16px;
    left: 0px;
    width: 0;
    height: 0;
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-bottom: 16px solid #cccccc;
  }

  &__InnerArrow {
    position: absolute;
    top: 1px;
    left: -15px;
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 15px solid #ffffff;
  }

  &__Body {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    background-color: #ffffff;
    list-style: none;
    padding: 0;
    margin: 0;

    &__Item {
      font-size: 16px;
      color: #111111;
      padding: 16px;
      border-bottom: 1px solid #cccccc;
      &:hover {
        background-color: #eeeeee;
      }
    }
  }
}

            
          
!
            
              class FittingRoom extends React.Component {
  constructor (props) {
    super(props)
    this.state = {
      shouldShowActionsMenu: false
    }
    this.toggleActionsMenu = this.toggleActionsMenu.bind(this)
  }

  toggleActionsMenu () {
    this.setState({shouldShowActionsMenu: !this.state.shouldShowActionsMenu})
  }

  isOccupied (fittingRoom) {
    return !_.isEmpty(fittingRoom.fittingRoomTicket)
  }

  isOpen (fittingRoom) {
    return fittingRoom.open === true
  }

  renderOccupiedFittingRoom (fittingRoom) {
    let walkIn = fittingRoom.fittingRoomTicket.walkIn

    return (
      <div className='FittingRoom__Container'>
        <div className='FittingRoom__Label'>
          {fittingRoom.label}
        </div>
        <div className='FittingRoom__Status'>
          {walkIn.firstName} {walkIn.lastName}
        </div>
        <div className='FittingRoom__Timer'>
          {formatTimeElapsed(fittingRoom.fittingRoomTicket.startTime)}
        </div>
        {this.state.shouldShowActionsMenu && <FittingRoomActionsMenu
          toggleActionsMenu={this.toggleActionsMenu}
          adjustFittingRoom={() => { this.props.removeWalkIn(walkIn, fittingRoom.fittingRoomTicket) }}
          adjustFittingRoomText={'Mark as Done'} />
        }
      </div>
    )
  }

  renderFittingRoom (fittingRoom) {
    return (
      <div className='FittingRoom__Container'>
        <div className='FittingRoom__Label'>
          {fittingRoom.label}
        </div>
        <div className='FittingRoom__Status'>
          {fittingRoom.open ? 'Open' : 'Closed'}
        </div>
        {this.state.shouldShowActionsMenu && <FittingRoomActionsMenu
          toggleActionsMenu={this.toggleActionsMenu}
          adjustFittingRoom={() => this.props.updateFittingRoom(fittingRoom)}
          adjustFittingRoomText={fittingRoom.open ? 'Close Fitting Room' : 'Open Fitting Room'} />}
      </div>
    )
  }

  render () {
    let {fittingRoom} = this.props
    let status
    let fittingRoomComponent

    if (this.isOccupied(fittingRoom)) {
      status = 'Occupied'
      fittingRoomComponent = this.renderOccupiedFittingRoom(fittingRoom)
    } else if (this.isOpen(fittingRoom)) {
      status = 'Open'
        fittingRoomComponent = this.renderFittingRoom(fittingRoom)
    } else {
      status = 'Closed'
      fittingRoomComponent = this.renderFittingRoom(fittingRoom)
    }

    return (
      <div className={`FittingRoom FittingRoom--${status}`} onClick={this.toggleActionsMenu}>
        {fittingRoomComponent}
      </div>
    )
  }
}

class FittingRoomActionsMenu extends React.Component {
  constructor (props) {
    super(props)

    this.setWrapperRef = this.setWrapperRef.bind(this)
    this.handleClickOutside = this.handleClickOutside.bind(this)
  }

  componentDidMount () {
    document.addEventListener('mousedown', this.handleClickOutside)
  }

  componentWillUnMount () {
    document.removeEventListener('mousedown', this.handleClickOutside)
  }

  setWrapperRef (node) {
    this.wrapperRef = node
  }

  handleClickOutside (event) {
    // THIS ALLOWS THE TOGGLE TO REMAIN FUNCTIONAL WHEN THE MENU IS OPEN
    let toggles = Array.prototype.slice.call(document.querySelectorAll('.FittingRoom'))
    if (this.wrapperRef && !this.wrapperRef.contains(event.target) && !toggles.some((t) => t.contains(event.target))) {
      this.props.toggleActionsMenu()
    }
  }

  render () {
    return (
      <div ref={this.setWrapperRef}>
        <div className='FittingRoomActionsMenu'>
          <div className='FittingRoomActionsMenu__Arrow'>
            <div className='FittingRoomActionsMenu__InnerArrow' />
          </div>
          <ul className='FittingRoomActionsMenu__Body'>
            <li className='FittingRoomActionsMenu__Body__Item' onClick={this.props.adjustFittingRoom}>
              {this.props.adjustFittingRoomText}
            </li>
          </ul>
        </div>
      </div>
    )
  }
}

let fittingRoom = {
  label: "1",
  open: true,
  fittingRoomTicket: null
}

ReactDOM.render(<FittingRoom fittingRoom={fittingRoom}/>,
document.getElementById('app'))
            
          
!
999px
Loading ..................

Console