| 1 | <template lang="pug"> |
| 2 | main |
| 3 | .row |
| 4 | .nopadding.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 |
| 5 | label(for="prefixFilter") {{ st.tr["Type first letters..."] }} |
| 6 | input#prefixFilter(v-model="curPrefix") |
| 7 | .variant.col-sm-12.col-md-5.col-lg-4( |
| 8 | v-for="(v,idx) in filteredVariants" |
| 9 | :class="{'col-md-offset-1': idx%2==0, 'col-lg-offset-2': idx%2==0}" |
| 10 | ) |
| 11 | router-link(:to="getLink(v.name)") |
| 12 | h4.boxtitle.text-center {{ v.name }} |
| 13 | p.description.text-center {{ st.tr[v.desc] }} |
| 14 | </template> |
| 15 | |
| 16 | <script> |
| 17 | import { store } from "@/store"; |
| 18 | export default { |
| 19 | name: "my-variants", |
| 20 | data: function() { |
| 21 | return { |
| 22 | curPrefix: "", |
| 23 | st: store.state, |
| 24 | }; |
| 25 | }, |
| 26 | computed: { |
| 27 | filteredVariants: function () { |
| 28 | const capitalizedPrefix = this.curPrefix.replace(/^\w/, c => c.toUpperCase()); |
| 29 | const variants = this.st.variants |
| 30 | .filter( v => { |
| 31 | return v.name.startsWith(capitalizedPrefix); |
| 32 | }) |
| 33 | .map( v => { |
| 34 | return { |
| 35 | name: v.name, |
| 36 | desc: v.description, |
| 37 | }; |
| 38 | }) |
| 39 | .sort((a,b) => { |
| 40 | return a.name.localeCompare(b.name); |
| 41 | }); |
| 42 | return variants; |
| 43 | }, |
| 44 | }, |
| 45 | methods: { |
| 46 | getLink: function(vname) { |
| 47 | return "/variants/" + vname; |
| 48 | }, |
| 49 | }, |
| 50 | }; |
| 51 | </script> |
| 52 | |
| 53 | <style lang="sass" scoped> |
| 54 | // TODO: box-shadow or box-sizing ? https://stackoverflow.com/a/13517809 |
| 55 | .variant |
| 56 | box-sizing: border-box |
| 57 | border: 1px solid brown |
| 58 | background-color: lightyellow |
| 59 | &:hover |
| 60 | background-color: yellow |
| 61 | a |
| 62 | color: #663300 |
| 63 | text-decoration: none |
| 64 | .boxtitle |
| 65 | font-weight: bold |
| 66 | margin-bottom: 0 |
| 67 | .description |
| 68 | @media screen and (max-width: 767px) |
| 69 | margin-top: 0 |
| 70 | </style> |