Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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#filterList.container
  %div.filters
    %strong Filter:
    %ul.filter
      %li.filter__item
        %button.filter__button{"@click":"tag = ''", ":class":"{'filter__button--active': tag === ''}"} All
      - ['CSS', 'Animation', 'React'].each do |tag|
        %li.filter__item
          %button.filter__button{"@click":"tag = '" + tag+"'", ":class":"{'filter__button--active': tag === '"+tag+"'}"}= tag
    %p{"aria-live":"polite"} Showing {{ postCount }} posts tagged <em>{{ tag ? tag : 'all' }}</em>
        

  %div.posts
    - [{title: 'Are There Random Numbers in CSS?',
    excerpt: 'CSS allows you to create dynamic layouts and interfaces on the web, but as a language, it is static: once a value is set, it cannot be changed.',
    tags: ['CSS', 'Animation']},
    {title: 'Working with Framer Motion',
    excerpt: 'Matt Perry from Framer and I take a look at the React animation library Framer Motion. First, we take a look at how simple the API is.',
    tags: ['Animation', 'React']},
    {title: 'Digging Into the Preview Loading Animation in WordPress',
    excerpt: 'WordPress shipped the Block Editor (aka Gutenberg) back in version 5.0 and with it came a snazzy new post preview screen that shows the WordPress logo drawing itself while the preview loads.',
    tags: ['Animation']},
    {title: 'Grid, content re-ordering and accessibility',
    excerpt: 'Take this: That HTML ends up in the DOM that way (and thus how it is is exposed to assistive technology), and by default, those list items are also visually shown in that order. ',
    tags: ['CSS', 'Accessibility']},
    {title: 'Revisiting prefers-reduced-motion, the reduced motion media query',
    excerpt: 'Two years ago, I wrote about prefers-reduced-motion, a media query introduced into Safari 10.1 to help people with vestibular and seizure disorders use the web.',
    tags: ['Animation', 'Accessibility']},
    {title: 'Tabs: It’s Complicated',
    excerpt: 'I’ve said before one quick and powerful thing you can learn as a front-end developer just getting starting with JavaScript is changing classes.',
    tags: ['Accessibility', 'React']},
    {title: 'The Dark Side of the Grid',
    excerpt: 'Manuel Matuzovic makes the point that in order to use CSS grid in some fairly simple markup scenarios, we might be tempted to flatten our HTML ',
    tags: ['Accessibility', 'CSS']}].each do |post|
      %article.post{ "v-if":post[:tags].to_json + ".includes(tag) || tag === ''"}
        %header.post__header
          %h2= post[:title]
        %p= post[:excerpt]
        %footer.post__footer
          %span= "Tagged: " + post[:tags].join(", ")
  
              
            
!

CSS

              
                /* RGB */
$white: #FDFDFF;
$primary: #3F5B69;
$primary--light: lighten($primary, 10%);
$primary--dark: #243B4A;
$secondary: #393D3F;

body {
  margin: 0;
  height: 100%;
  display: flex;
}

.container {
  font-size: 20px;
  color: $white;
  background: $primary--dark;
  background: linear-gradient(225deg, $primary--dark 0%, $primary 50%) no-repeat;
  padding: 1em;
  height: 100%;
}
.filter {
  display: flex;
  list-style-type: none;
  margin: 0;
  padding: 0;
}
.filter__item:not(:last-child) {
  margin-inline-end: .5rem;
}
.filter__button {
  border: 2px solid $white;
  background: none;
  color: $white;
  padding: .5rem;
  font-size: 1rem;
  
  &:hover, &:focus {
    background: $primary--dark;
    color: $white;
    cursor: pointer;
    outline: 0;
  }
  &--active, &--active:hover, &--active:focus {
    background: $primary--dark;
    border-color: $white;
    color: $white;
    cursor: default;
  }
}

.posts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  width: 100%;
  margin: 1rem 0;
  padding: 0;
}
  
.post {
  padding: .5rem;
  margin: .5rem;
  color: $white;
  background: none;
  border: 2px solid $white;
  text-align: center;
  display: flex;
  flex-direction: column;
  
  &:hover, &:focus {
    background: $primary;
  }
}

.post__footer {
  margin-top: auto;
}
              
            
!

JS

              
                 new Vue({
   el: '#filterList',
   data: {
     'tag': '',
     'postCount': ''
   },
   methods: {
     getCount: function(){
       let posts = this.$el.getElementsByTagName('article');
       return posts.length;
     }
   },
   beforeMount: function(){
     this.postCount = this.getCount();
   },
   updated: function(){
     this.postCount = this.getCount();
   }
});
              
            
!
999px

Console