Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
  <div class="artboard t-material-light" id="artboard-1"></div>
  <div class="artboard t-material-dark" id="artboard-2"></div>
</div>

<small class="let-me-know">If You like my work <i>&#10084;</i> let me know.</small>
              
            
!

CSS

              
                // TEMPLATE SETUP
@mixin flexbox-c-c {
  display: flex;
  align-items: center;
  justify-content: center;
}

$color-white: #fff;
$color-black: #000;

$theme-material-light: (
  statusBar: #e0e0e0,
  appBar: #f5f5f5,
  appBackground: #fafafa,
  modalAndCard: #fff,
  textPrimary: rgba(#000, .87),
  textSecondary: rgba(#000, .54),
  textDisabledAndContext: rgba(#000, .38),
  dividers: rgba(#000, .12)
);
  
$theme-material-dark: (
  statusBar: #000,
  appBar: #212121,
  appBackground: #303030,
  modalAndCard: #424242,
  textPrimary: rgba(#fff, 1),
  textSecondary: rgba(#fff, .7),
  textDisabledAndContext: rgba(#fff, .5),
  dividers: rgba(#fff, .12)
);

$theme-app: (
  base: #00aa8d,
  lighter: #00bf92,
  darker: #008975
);

@function theme-light ($key) {
  @if map-has-key($theme-material-light, $key) {
    @return map-get($theme-material-light, $key)
  }
  
  @else {
    @warn "No such key in map"
  }
}
@function theme-dark ($key) {
  @if map-has-key($theme-material-dark, $key) {
    @return map-get($theme-material-dark, $key)
  }
  
  @else {
    @warn "No such key in map"
  }
}
@mixin apply-child-themes ($color, $properties...) {
  .t-material-light & {
    @each $property in $properties {
      #{$property}: theme-light($color);
    }
  }
  .t-material-dark & {
    @each $property in $properties {
      #{$property}: theme-dark($color);
    }
  }
}
@mixin hidden-visually () {
  border: 0 !important;
  clip: rect(0 0 0 0) !important;
  height: 1px !important;
  margin: -1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  position: absolute !important;
  width: 1px !important;
}
@function theme-app ($key) {
  @if map-has-key($theme-app, $key) {
    @return map-get($theme-app, $key)
  }
  
  @else {
    @warn "No such key in map"
  }
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  @include flexbox-c-c;
  
  background-color: rgba(#1B2B34, .5);
  position: relative;
}

.container {
  display: grid;
  grid-template-columns: 200px 200px;
  grid-template-rows: 200px;
  grid-column-gap: 20px;
  grid-row-gap: 20px;
  justify-items: stretch;
  align-items: stretch;
}

.artboard {
  @include flexbox-c-c;
  
  &.t-material-light {
    background-color: map-get($theme-material-light, appBackground);
  }
  
  &.t-material-dark {
    background-color: map-get($theme-material-dark, appBackground);
  }
}

.let-me-know {
  bottom: 10px;
  color: rgba($color-white, 0.83);
  font-weight: 500;
  font-family: Montserrat, sans-serif;
  position: absolute;
  right: 10px;
  z-index: 0;
  
  i {
    padding: 0 3px;
    color: rgba(232, 41, 41, 0.9);
    font-size: larger;
  }
}

@keyframes ringing {
  0%, 100% {
    transform: rotate(0)
  }
  
  20% {
    transform: rotate(10deg)
  }
  
  40%, 80% {
    transform: rotate(-6deg);
  }
  
  60% {
    transform: rotate(6deg);
  }
}

@keyframes clapp {
  $_x: 6px;
  
  0%, 100% {
    transform: translate($_x, 18px) rotate(0);
  }
  
  20% {
    transform: translate($_x + 4px, 18px) rotate(-10deg);
  }
  
  40% {
    transform: translate($_x - 4px, 18px) rotate(10deg);
  }
  
  60% {
    transform: translate($_x + 3px, 18px) rotate(-8deg);
  }
  
  80% {
    transform: translate($_x - 3px, 18px) rotate(8deg);
  }
}

// REACT COMPONENT
.notification-bell {
  @include apply-child-themes(textDisabledAndContext, color);
  
  animation-timing-function: ease;
  cursor: pointer;
  transform-origin: 50% 0%;
  position: relative;
  transition: 200ms ease-in-out color;
  user-select: none;
  
  &:after {
    @include apply-child-themes(appBackground, 'border-color');
    
    background-color: theme-app(lighter);
    border: 2px solid;
    border-radius: 11px;
    content: attr(data-count);
    color: $color-white;
    display: block;
    font-size: 10px;
    font-family: helvetica;
    height: 9px;
    line-height: 8px;
    min-width: 9px;
    padding: 4px;
    position: absolute;
    right: 0px;
    text-align: center;
    top: 3px;
    transition: 100ms ease-in-out all;
  }
  
  &[data-count='0'] {
    &:after {
      @include hidden-visually;
    }
  }
  
  &.is-muted {
    
    &:after {
      content: '';
      color: transparent;
      height: 2px;
      min-width: 0;
      padding: 2px;
      right: 4px;
      top: 4px;
      width: 2px;
    }
  }
  
  &:not([data-count='0']) {
    @include apply-child-themes(textPrimary, color);
    
    &.is-muted {
      @include apply-child-themes(textSecondary, color);
    }
  }
  
  &:hover {
    @include apply-child-themes(textDisabledAndContext, color);
    
    &:after {
      background-color: theme-app(base);
    }
  }
  
  &.is-animating {
    animation: ringing 800ms;
    
    .notification-bell__clapper {
      animation: clapp 800ms;
    }
  }
  
  .notification-bell__bow,
  .notification-bell__clapper {
    fill: currentColor;
  }
  
  svg {
    overflow: visible!important; //override reset
  }
}


.notification-bell__clapper {
  animation-timing-function: inherit; 
  transform: translate(6px, 18px) rotate(0);
  transform-origin: inherit;
}
              
            
!

JS

              
                const { Component } = React
const soundUrl = `https://ia800203.us.archive.org/14/items/slack_sfx/been_tree.mp3`
const notificationSound = new Audio(soundUrl)


class NotificationContainer extends Component {
  constructor () {
    super()
    
    this.state = {
      count: 0,
      isAnimating: false,
      mute: false
    }
    
    this.handleClick = this.handleClick.bind(this)
    this.notify = this.notify.bind(this)
  }
  
  render () {
    const { count, mute, isAnimating } = this.state
    return (
      <div onClick={ this.handleClick }>
        <Notification
          count={ count }
          isAnimating={ isAnimating }
          mute={ mute } />
      </div>
    )
  }
  
  notify () {
    if (this.state.mute) {
      return null
    }
    
    this.setState({
      count: this.state.count += 1,
      isAnimating: !this.state.mute ? true : false
    })
    
    notificationSound.play()
    setTimeout(() => this.setState({ isAnimating: false }), 1000)
  }
  
  componentDidMount () {
    this.countNotifications = setInterval(this.notify, 2000)
  }
  
  componentWillUnmount () {
    clearInterval(this.countNotifications)
  }
  
  
  handleClick () {
   this.setState({ mute: !this.state.mute })
    console.log(this.state)
  }
}


const NotificationIcon = () => (
  <svg width='42' height='40' viewBox='0 0 21 20'>
    <g transform='translate(2, 0)'>
      <path className='notification-bell__bow' d='M15,8.5 C15,5.43 12.86,2.86 10,2.18 L10,1.5 C10,0.671572875 9.32842712,0 8.5,0 C7.67157288,0 7,0.671572875 7,1.5 L7,2.18 C4.13,2.86 2,5.43 2,8.5 L2,14 L0,16 L0,17 L17,17 L17,16 L15,14 L15,8.5 Z' />
      <path className='notification-bell__clapper' d='M2.5,2 C2.64,2 2.77,2 2.9,1.96 C3.55,1.82 4.09,1.38 4.34,0.78 C4.44,0.54 4.5,0.27 4.5,0 L0.5,0 C0.5,1.1045695 1.3954305,2 2.5,2 L2.5,2 Z'  />
    </g>
  </svg>
 )

const Notification = ({ count, mute, isAnimating }) => (
  <div
    className={`notification-bell ${isAnimating ? 'is-animating' : ''} ${mute ? 'is-muted' : ''}`}
    data-count={ count > 9 ? '9+' : count }>
    <NotificationIcon />
  </div>
)





ReactDOM.render(<NotificationContainer />, document.getElementById('artboard-1'))
ReactDOM.render(<NotificationContainer />, document.getElementById('artboard-2'))
              
            
!
999px

Console