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

              
                <body>
    <div id="app">
        <div id="sort-bar">
            <select name="sortBy" id="select"  v-model="sortBy">
                <option value="alphabetically">Alphabetically</option>
                <option value="relevance">Relevance</option>
            </select>
            <button v-on:click="ascending = !ascending" class="sort-button">
                <i v-if="ascending" class="fa fa-sort-up"></i>
                <i v-else class="fa fa-sort-down"></i>
            </button>
            <select v-model="industryType">
                <option value="">All</option>
                <option v-for="industry in uniqueIndustry" :value="industry">{{industry}}</option>
            </select>
            <select v-model="selectedCountry">
                <option value="">All</option>
                <option v-for="country in uniqueCountry" :value="country">{{country}}</option>
            </select>
            <input type="text" v-model="searchValue" placeholder="Search" id="search-input"></input>
            <i class="fa fa-search"></i>
        </div>
        <!-- Where the array of results get rendered as cards -->
        <div id="container">
            <div class="card" v-for="item in filteredResults">
                <div class="image">
                    <img :src="item.image" />
                </div>
                <div class="content">
                    <h1 class="title">
                        {{ item.name }}
                    </h1>
                    <p>
                        {{ item.industry }}
                    </p>
                    <p>
                        {{ item.country }}
                    </p>
                    <span>
                        Relevance {{ item.relevance }}
                    </span>
                </div>
            </div>
        </div>
          <footer>
            <span> Vue multiple filter options <a href="https://www.lzf.ro">#lzfro</a> </span>
        </footer>
    </div>
</body>
              
            
!

CSS

              
                  body {
        background: #20262E;
        padding: 20px;
        font-family: Helvetica;
    }
    #app {
        background: #fff;
        border-radius: 4px;
        padding: 20px;
        transition: all 0.2s;
    }
    h2 {
        font-weight: bold;
        margin-bottom: 15px;
    }
    h3 {
        font-weight: 600;
        font-size: 16px;
    }
    #container {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    .card {
        border-radius: 5px;
        box-shadow: rgba(0, 0, 0, 0.3) 0 5px 10px;
        margin: 10px;
        width: 40%;
        display: flex;
    }
    .image img{
        border-radius: 5px;
        box-shadow: rgba(0, 0, 0, 0.3) 0 5px 10px;
        display: flex;
    }
    .content {
        padding: 30px;
    }
    .title {
        font-size: 18px;
        font-weight: 600;
    }
    #sort-bar {
        width: 80%;
        background-color: #00c88278;
        display: flex;
        flex-wrap: wrap;
        padding: 10px;
        margin: 0 auto;
    }
    .sort-button {
        background-color: rgba(0,0,0,0);
        border: none;
        height: 50px;
        width: 50px;
    &:hover {
         background-color: rgba(0,0,0, 0.2);
         cursor: pointer;
     }
    }
    #sort-label {
        font-size: 12px;
    }
    #ascending-icon {
        height: 100%;
        width: 30px;
    }
    #select {
        background-color: rgba(0,0,0, 0);
        border: none;
    }
    #search-input {
        margin-right: 10px;
    }
    select {
        width: 20%;
        height: 50px;
        border-radius: 5px;
        box-shadow: none;
        border: 1px solid #ced6e0;
        transition: all 0.3s ease-in-out;
        margin-right: 10px;
    }
    i.fa-search {
        display: flex;
        align-items: center;
    }
    footer {
        height: 50px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
              
            
!

JS

              
                new Vue({
        el: '#app',
        data() {
            return {
                ascending: true,
                sortBy: 'alphabetically',
                industryType: '',
                selectedCountry: '',
                searchValue: '',
                items: [
                    {
                        "name": "Allianz",
                        "industry": "Banking & Finance",
                        "country": "Germany",
                        "relevance": "7",
                        "image" : "https://picsum.photos/seed/picsum/200/200"
                    },
                    {
                        "name": "Cathay United Bank",
                        "industry": "Banking & Finance",
                        "country": "China",
                        "relevance": "1",
                        "image" : "https://picsum.photos/seed/picsum/200/200"
                    },
                    {
                        "name": "Yale University",
                        "industry": "Education",
                        "country": "United States of America",
                        "relevance": "10",
                        "image" : "https://picsum.photos/seed/picsum/200/200"
                    },
                    {
                        "name": "Johnson & Johnson",
                        "industry": "Healthcare",
                        "country": "United Kingdom",
                        "relevance": "8",
                        "image" : "https://picsum.photos/seed/picsum/200/200"
                    },
                    {
                        "name": "Accenture",
                        "industry": "Audit & Advisory",
                        "country": "United Kingdom",
                        "relevance": "7",
                        "image" : "https://picsum.photos/seed/picsum/200/200"
                    },
                    {
                        "name": "Deloitte",
                        "industry": "Audit & Advisory",
                        "country": "United Kingdom",
                        "relevance": "7",
                        "image" : "https://picsum.photos/seed/picsum/200/200"
                    },
                    {
                        "name": "Intel",
                        "industry": "Technology & Telecom",
                        "country": "United States of America",
                        "relevance": "10",
                        "image" : "https://picsum.photos/seed/picsum/200/200"
                    },
                    {
                        "name": "Orange",
                        "industry": "Technology & Telecom",
                        "country": "France",
                        "relevance": "9",
                        "image" : "https://picsum.photos/seed/picsum/200/200"
                    },
                    {
                        "name": "Vodafone",
                        "industry": "Technology & Telecom",
                        "country": "United Kingdom",
                        "relevance": "9",
                        "image" : "https://picsum.photos/seed/picsum/200/200"
                    },
                    {
                        "name": "U.S. Department of Commerce",
                        "industry": "Gov & Public Sector",
                        "country": "United States of America",
                        "relevance": "10",
                        "image" : "https://picsum.photos/seed/picsum/200/200"
                    }
                ]
            };
        },
        computed: {
            filteredResults() {
                let tempResults = this.items;
                // Process selected Industry Type
                if(this.industryType)
                    tempResults = tempResults.filter((item) => {
                        return (item.industry == this.industryType);
                })
                // Process selected Country
                if(this.selectedCountry)
                    tempResults = tempResults.filter((item) => {
                                return (item.country == this.selectedCountry)
                })
                // Process search input
                if (this.searchValue != '' && this.searchValue) {
                    tempResults = tempResults.filter((item) => {
                                return item.name
                                        .toUpperCase()
                                        .includes(this.searchValue.toUpperCase())
                            })
                }
                // Sort by alphabetical order
                tempResults = tempResults.sort((a, b) => {
                            if (this.sortBy == 'alphabetically') {
                    let fa = a.name.toLowerCase(), fb = b.name.toLowerCase()

                    if (fa < fb) {
                        return -1
                    }
                    if (fa > fb) {
                        return 1
                    }
                    return 0
                    // Sort by relevance
                } else if (this.sortBy == 'relevance') {
                    return a.relevance - b.relevance
                }
            })
                // Show sorted array in descending or ascending order
                if (!this.ascending) {
                    tempResults.reverse()
                }

                return tempResults
            },
            uniqueIndustry: function() {
                // Fetch items industry for dropdown select and store uniques in array
                var Remove_duplicate_Industry = [];
                for(var i =0; i < this.items.length; i++) {
                    if(Remove_duplicate_Industry.indexOf(this.items[i].industry) === -1) {
                        Remove_duplicate_Industry.push(this.items[i].industry)
                    }
                }
                return Remove_duplicate_Industry;
            },
            uniqueCountry: function() {
                // Fetch items country for dropdown select and store uniques in array
                var Remove_duplicate_Country = [];
                for(var i =0; i < this.items.length; i++) {
                    if(Remove_duplicate_Country.indexOf(this.items[i].country) === -1) {
                        Remove_duplicate_Country.push(this.items[i].country)
                    }
                }
                return Remove_duplicate_Country;
            }
        }
    })
              
            
!
999px

Console