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

              
                mixin layerR(n, c)
  if --n
    .layer(id=`layer${n}`)
      each type, position in {"zero":"number","one":"number","two":"number","three":"number","four":"number","five":"number","six":"number","seven":"number","eight":"number","nine":"number","plus":"operator","minus":"operator","multiply":"operator","equals":"operator"}
        if (position == "equals")
          input(type="radio" name=position class=position+' '+type).button
        else
          input(type="radio" name=`buttons${n}` class=position+' '+type).button
      .blank.button
      input(type="reset" class="reset" value="C" form="container").button
      if n == 1
        .layer.second-last
          input(type="radio" name="equals" class="equals operator").button
          input(type="reset" class="reset" value="C" form="container").button
          .layer.last
            input(type="reset" class="reset" value="C" form="container").button
            .answer
              - for (index=0;index<c;index++)
                .digit 
      +layerR(n, c)

mixin layer(n)
  +layerR(n + 1, n)
    
form.container(id="container")
  +layer(7)
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Open+Sans&family=VT323&display=swap')
$buttons: ("zero":"0","one":"1","two":"2","three":"3","four":"4","five":"5","six":"6","seven":"7","eight":"8","nine":"9","plus":"+","minus":"-","multiply":"*","equals":"=")
@mixin layerR($n, $i, $c)
  @if $n != 0
    #layer#{$n}
      --checked#{$i}: initial
      --not-checked#{$i}: #{" "}
      --is-operator#{$i}: initial
      --is-not-operator#{$i}: #{" "}
      --is-number#{$i}: initial
      --expression#{$i}: + 0
      
      &>.number:checked ~ .layer
        --is-number#{$i}: #{" "}
      &>.operator
        &:not(.equals):checked ~ .layer
          --is-operator#{$i}: #{" "}
          --is-not-operator#{$i}: initial
      @each $name,$symbol in $buttons
        @if $name != "equals"
          &>.#{$name}
            &:checked ~ .layer
              --symbol#{$i}: #{$symbol} 
              --char#{$i}: "#{$symbol}"
              --checked#{$i}: #{" "}
              --not-checked#{$i}: initial
              
    @if $n == 1
      .answer
        $valid: ()
        $equation: ()
        @for $j from 1 to $c + 1
        
          --expression#{$j}: var(--is-operator#{$j - 1}, var(--is-operator#{$j}, var(--plus))) var(--symbol#{$j}) var(--is-operator#{$j}, var(--multiply) var(--power#{$j}))
        
          $power: ""
          $term: "var(--is-operator#{$c + 1})"
          @for $k from $j to $c + 1   
            $power: "var(--is-operator#{$c - ($k - $j) + 1}, var(--not-checked#{$c - ($k - $j) + 1}, var(--times-ten) #{$power}))"
            $term: "var(--is-operator#{$c - ($k - $j)}, var(--not-checked#{$c - ($k - $j)}, var(--expression#{$c - ($k - $j)}) #{$term}))"
          --power#{$j}: calc(#{"1 " + $power})
          --term#{$j}: calc(#{$term})

          --T2#{$j}: var(--is-operator#{$j - 1}) var(--term#{$j})
          --F2#{$j}: var(--is-operator#{$j - 1}, var(--blank))
          --term-or-blank#{$j}: var(--T2#{$j}, var(--F2#{$j}))

          --T3#{$j}: var(--is-operator#{$j}) var(--expression#{$j})
          --F3#{$j}: var(--is-operator#{$j}, var(--term-or-blank#{$j}))
          --final#{$j}: var(--T3#{$j}, var(--F3#{$j}))
          
          $equation: append($equation, var(--final#{$j}))
          $valid: append($valid, var(--is-not-operator#{$j}, var(--is-number#{$j - 1}) var(--is-number#{$j + 1})))

        --equation: #{$equation}
        --valid: #{$valid}

        &>.digit
          @for $i from 1 to $c + 1
            &:nth-child(#{$i})::before
              content: var(--submit, var(--char#{$i}))

    @include layerR($n - 1, $i + 1, $c)
    
@mixin layer($n)
  --blank: #{" "}
  --plus: +
  --multiply: *
  --times-ten: * 10
  --submit: initial
  --is-operator0: #{" "}
  --is-operator#{$n + 1}: #{" "}
  --is-number0: initial
  --is-number#{$n + 1}: initial
  @include layerR($n, 1, $n)
    
html
  width: 100vw
  height: 100vh
  body
    width: 100%
    height: 100%
    display: flex
    box-sizing: border-box
    *,*::before,*::after
      box-sizing: inherit

.container
  --width: 100vmin
  --break-point: clamp(0px, var(--width) - 500px, 50vmin)
  width: calc(var(--width) - var(--break-point) - 2%)
  height: calc((var(--width) - var(--break-point)) * (60/50))
  border: 1px solid black
  margin: auto
  position: relative
  overflow: hidden
  border-radius: 5%
  font-size: var(--width)
  @include layer(7)
            
.layer
  width: 100%
  height: 100%
  position: absolute
  display: grid
  grid-template-columns: repeat(4, 24%)
  grid-template-rows: repeat(5, 19.25%)
  grid-template-areas: "answer answer answer answer" "seven eight nine plus" "four five six minus" "one two three multiply" "blank zero reset equals"
  grid-gap: 1% 1.5%
  padding: 6% 3% 4%
  &:not(.container > .layer)
    pointer-events: none
    &::before
      opacity: 0
    & > .button
      opacity: 0
  &::before
    content: ''
    position: absolute
    width: 100%
    height: 100%
    background-color: white

.answer
  display: flex
  justify-content: flex-end
  align-items: center
  grid-area: answer
  border: 0.025em solid black
  padding: 0 1.5%
  max-width: 100%
  transform: translatey(-5%)
  font: calc((100% - var(--break-point)) * (28/100)) "VT323", monospace
  letter-spacing: min(0.04em, 4px)
  line-height: 0.5
  &::before
    counter-reset: convert calc(var(--equation))
    --placeholder: var(--submit, var(--checked1, "0"))
    --answer: var(--valid) var(--submit) counter(convert)
    --error: var(--valid, var(--submit) "ERROR")
    content: var(--placeholder) var(--answer, var(--error))
    margin-right: var(--valid, var(--submit) auto)
    transform: inherit
    
.digit
  flex: 0 1
  transform: inherit
    
.button
  width: 100% 
  height: 100%
  margin: 0
  border: 0.04em solid rgba(0,0,0,0.5)
  appearance: none
  font: calc((100% - var(--break-point)) * (11.5/100)) "Open Sans"
  display: flex
  justify-content: center
  align-items: center
  border-radius: 15%
  color: rgba(0,0,0,0.75)
  position: relative
  -webkit-tap-highlight-color: transparent
  user-select: none
  &.blank
    grid-area: blank
    background-color: rgba(0,0,0,0.25)
  &.reset
    grid-area: reset
    background-color: white
    padding: 0
    &::before
      content: 'foo'
      width: 100px
      height: 100px
      background: blue
      display: block
      position: absolute
      
  @each $name, $symbol in $buttons
    &.#{$name}
      grid-area: #{$name}
      &::before
        content: $symbol
  &.equals:checked 
    & ~ .reset
      box-shadow: inset 0 0 0 0.05em rgba(0,0,255,0.6)
    & ~ .layer
      & .last
        pointer-events: auto
      & .answer
        --submit: #{" "}
  &:not(.equals):checked
    opacity: 0
    & ~ .layer
      pointer-events: auto
      &:not(.second-last)::before
        opacity: 1
      & > .button
        opacity: 1
  &:not(.blank):not(.equals:checked):hover
    background-color: rgba(0,0,255,0.25)
    cursor: pointer
  &:focus
    outline: none
    



              
            
!

JS

              
                
              
            
!
999px

Console