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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <main>
	<progress-arc :value="value" :max="maxValue">
		<section class="local-content">
			<h2>{{ heading }}...</h2>
			<p>{{ info }}</p>
		</section>
	</progress-arc>

	<div class="control-bar" title="playground...">
		<input type="number" :value="value" min="0" max="999" readonly />
		<input type="range" :value="value" @change="setValue" min="0" :max="maxValue" /> 
		<input type="number" :value="maxValue" @input="setMaxValue" min="0" max="999" />
		<input type="text" v-model="info" />
	</div>
</main>


              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Oswald');

.progress-arc {
	pointer-events: none;
	position: relative;
	// min-width: 10em;
	max-width: 35vw;
	font-family: "Oswald", sans-serif;
	
	display: flex;
	align-items: center;
	justify-content: center;
	
	svg {
		position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
	}
	
	&--value {
		fill: var(--color);
		text-anchor: middle;
		dominant-baseline: central;
		font-size: 50%;
		
		&--bg {
			fill: none;
			stroke: var(--color);
			stroke-width: 2.5;
		}
		
		&--mask {
			fill: black;
			stroke: black;
			stroke-width: 0;
		}
	}
		
	// svg rings
	&--ring {
		fill: none;
		stroke: var(--color);
		opacity: .3;
		stroke-linecap: round;
		stroke-width: 6;
		transform: rotate(-35deg);
		transform-origin: 50% 50%;

		&--current {
			opacity: 1;
		}
	}
}

.local-content {
	padding: 20%;
	font-size: 2vw;
	
	* {
		margin: 0;
	}
}

input {
	font-family: inherit;
	font-size: inherit;
	background: none;
	color: inherit;
	border: 0;
	// text-decoration: underline;

	+ input {
		margin-left: 1em;
	}
	
	&[type="text"] {
		width: 100%;
	}
	&[type="text"],
	&[type="number"] {
		background: rgba(255, 255, 255, .3);
		padding: .3em;
		border-radius: .3em;
		border: 1px solid rgba(255, 255, 255, .4);
	}
	&[readonly] {
		opacity: .6;
		background: none;
	}
  &[type="range"] {
    appearance: none;
    outline: none;
    display: block;
    padding: 0;
    border: 0;
    width: auto;
    height: .25em;
    border-radius: 1em;
    cursor: pointer;
    font-size: inherit;
    background: currentcolor;

    // MOZILLA
    &::-moz-range-track {
      appearance: none;
      background: currentcolor;
      outline: none;
    }
    &::-moz-focus-outer {
      border: 0;
    }
    &::-moz-range-thumb {
      appearance: none;
      width: 1em;
      height: 1em;
      border: none;
      box-shadow: 0 0 0 .2em var(--color);
      border-radius: 1em;
      background: currentcolor;
      transform: scale(.7);
      transition: var(--timing) ease-out;
    }
    &::-moz-range-thumb:focus,
    &::-moz-range-thumb:active {
      appearance: none;
      transform: scale(1.5);
    }
    
    // BLINK/WEBKIT
    &::-webkit-slider-thumb {
      appearance: none;
      width: 1em;
      height: 1em;
      border: none;
      box-shadow: 0 0 0 .2em var(--color);
      border-radius: 1em;
      background: currentcolor;
      transform: scale(.8);
      transition: var(--timing) ease-out;
    }
    &::-webkit-slider-thumb:focus,
    &::-webkit-slider-thumb:active {
      appearance: none;
      transform: scale(1.05);
    }
  }
}

body {
	--color: #663490;
	margin: 0;
	background: #fffc79 linear-gradient(135deg, #ff2f92 0%, #fffc79 90%);
	color: var(--color);
	font-family: sans-serif;
	display: flex;
	min-height: 100vh;
}

main {
	flex: 1;
	
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	
	> * {
		flex: 1;
	}
}

.control-bar {
	--color: #33344f;
	
	flex: none;
	align-self: stretch;
	background: var(--color);
	color: #fff;
	padding: 1em;
	text-align: center;
	display: flex;
	align-items: center;
	
	&::after {
		content: attr(title);
		position: absolute;
		bottom:100%;
		left: 0;
		padding: .85em 4em .85em 1em;
		background: transparent linear-gradient(60deg, #fff calc(100% - 3em), transparent  calc(100% - 3em));
		color: var(--color);
		text-transform: uppercase;
		font-size: .75em;
	}
	
	span {
		opacity: .5;
	}
}

              
            
!

JS

              
                Vue.component('progress-arc', {
  template: `
		<div class="progress-arc">
			<slot></slot>
			<svg viewBox="0 0 100 100" width="100%">
				<mask id="ring-mask">
					<rect fill="white" width="100%" height="100%" />
					<circle class="progress-arc--value--mask" r="12" cx="83.25%" cy="16.75%" />
				</mask>
				<g mask="url(#ring-mask)">
					<path v-once class="progress-arc--ring" :d="ringArc" />
					<path v-if="hasValidValue" class="progress-arc--ring progress-arc--ring--current" :d="arc" />
				</g>
				<circle class="progress-arc--value--bg" r="9" cx="83.25%" cy="16.75%" />
				<text class="progress-arc--value" x="83.5%" y="16.5%">{{ currentValue }}</text>
			</svg>
		</div>
  `,
  props: [
    'value',
    'max',
  ],
  data () {
    return {
      currentValue: 0,
    }
  },
  created () {
    this.precision = 2
    this.maxArc = 335
    this.duration = 350
  },
  mounted () {
    this.currentValue = this.value
  },
  watch: {
    value (newValue) {
      if(newValue === null || newValue === undefined) {
        this.currentValue = 0 //newValue
      } else {
        this.animateValue('currentValue', newValue, this.duration)
      }
    },
  },
  computed: {
    maxValue () {
      return this.max
    },
    pulse () {
      return this.setPulse(this.currentValue)
    },
    ringArc () {
      return this.setArc(this.maxArc)
    },
    arc () {
      return this.setArc(this.pulse)
    },
    hasValidValue () {
      return (this.currentValue !== null && this.currentValue !== undefined)
    },
  },
  methods: {
    setPulse (value) {
      return parseFloat(value / this.maxValue * this.maxArc).toFixed(this.precision)
    },
    setArc (value) {
      return this.describeVectorArc(50, 50, 47, 0, value)
    },
    polarToCartesian (centerX, centerY, radius, angleInDegrees) {
      let angleInRadians = (angleInDegrees) * Math.PI / 180.0

      return {
        x: (centerX + (radius * Math.cos(angleInRadians))).toFixed(this.precision),
        y: (centerY + (radius * Math.sin(angleInRadians))).toFixed(this.precision)
      }
    },
    describeVectorArc (x, y, radius, startAngle, endAngle) {
      const start = this.polarToCartesian(x, y, radius, endAngle);
      const end = this.polarToCartesian(x, y, radius, startAngle);
      const largeArcFlag = endAngle - startAngle <= 180 ? 0 : 1;

      return [
        'M', start.x, start.y,
        'A', radius, radius, 0, largeArcFlag, 0, end.x, end.y
      ].join(' ')
    },
    animateValue (thing, end, duration) {
      let range = end - this[thing]

      // calc step time to show all intermediate values
      let stepTime = Math.abs(Math.floor(duration / range))

      // get current time and calculate desired end time
      let startTime = new Date().getTime()
      let endTime = startTime + duration
      let timer

      let run = () => {
        let now = new Date().getTime()
        let remaining = Math.max((endTime - now) / duration, 0)
        let step = Math.round(end - (remaining * range))
        this[thing] = step
        if(step === end) {
          clearInterval(timer)
        }
      }

      // never go below minTimer
      stepTime = Math.max(stepTime, 50)
      timer = setInterval(run, stepTime)
      run()
    },
  }
})


// host app implementation - talks to component
let vm = new Vue({
  el: 'main',

  data: {
    value: 29,
    maxValue: 100,
		info: 'Snackwave vinyl helvetica artisan, tote bag man-braid photo booth unicorn.',
  },
	
	computed: {
		heading() {
			return this.info.length > 0 ? this.info.split(' ')[0] : ''
		},
	},

	methods: {
    setValue(event) {
      this.value = parseInt(event.target.value)
    },
    setMaxValue(event) {
      this.maxValue = parseInt(event.target.value)
    },
  },
})

              
            
!
999px

Console