11<template >
22 <div ref =" tableRef" class =" table-container" >
3- <table aria-live =" polite" class =" table cve-border-dark-blue is-striped is-hoverable" >
3+ <table aria-live =" polite" class =" table cve-border-dark-blue is-striped is-hoverable" >
44 <thead >
55 <tr >
6- <th v-for =" (header, index) in tableHeaders" :key =" index" >{{header}}</th >
6+ <th v-for =" (header, index) in tableHeaders" :key =" index" >{{ header }}</th >
77 </tr >
88 </thead >
99 <tbody >
10- <tr v-for =" (entry, index) in tableData" :key =" index"
10+ <tr
11+ v-for =" (entry, index) in tableData"
12+ :key =" index"
1113 :id =" entry.id"
1214 :ref =" entry.id"
1315 v-on:click =" selectRow(entry.id)"
14-
15- v-bind:class = " {'cve-term-active': selectedRow === entry.id} " >
16+ v-bind:class = " { 'cve-term-active': selectedRow === entry.id } "
17+ >
1618 <td class =" table-column-width" >
17- <a :href =" entry.termLink" v-bind:class =" {'selectTermLink': selectedRow === entry.id}" class =" has-text-weight-bold termLink" > {{ entry.term }} </a >
19+ <router-link
20+ :to =" '#' + entry.id"
21+ v-bind:class =" { selectTermLink: selectedRow === entry.id }"
22+ class =" has-text-weight-bold termLink"
23+ >
24+ {{ entry.term }}
25+ </router-link >
1826 </td >
19- <td v-if =" renderAsHTML" class =" cve-term-definition" v-html =" entry.definition" > </td >
20- <td v-else class =" cve-term-definition" >{{ entry.definition }} </td >
27+ <td
28+ v-if =" renderAsHTML"
29+ class =" cve-term-definition"
30+ v-html =" entry.definition"
31+ ></td >
32+ <td v-else class =" cve-term-definition" >{{ entry.definition }}</td >
2133 </tr >
2234 </tbody >
2335 </table >
2436 </div >
25- </template >
26-
27- <script >
37+ </template >
2838
29- export default {
30- name: " SearchTable" ,
31- props: {
32- tableData: {
33- type: Array ,
34- required: true ,
35- },
36- tableHeaders: {
37- type: Array ,
38- required: true ,
39- },
40- renderAsHTML: {
41- type: Boolean ,
42- default: false ,
43- required: false ,
44- }
39+ <script >
40+ export default {
41+ name: " SearchTable" ,
42+ props: {
43+ tableData: {
44+ type: Array ,
45+ required: true ,
4546 },
46- data () {
47- return {
48- selectedRow: null
49- };
47+ tableHeaders: {
48+ type: Array ,
49+ required: true ,
5050 },
51- mounted () {
52- let term = null ;
53-
54- // Add active term as a hash to scroll to it then select it
55- if (this .$route .query .activeTerm ) {
56- term = this .$route .query .activeTerm ;
57- this .$router .push ({hash: " #" + term })
58- this .selectRow (term)
59- }
60- // If route already has a hash, just select the term
61- else if (this .$route .hash ) {
62- term = this .$route .hash .slice (1 );
63- this .selectRow (term)
64- }
51+ renderAsHTML: {
52+ type: Boolean ,
53+ default: false ,
54+ required: false ,
6555 },
66- methods: {
67- selectRow (rowId ) {
68-
69- this .selectedRow = (rowId === this .selectedRow ? null : rowId)
70- }
56+ },
57+ data () {
58+ return {
59+ selectedRow: null ,
60+ };
61+ },
62+ mounted () {
63+ let term = null ;
64+
65+ if (this .$route .hash ) {
66+ term = this .$route .hash .slice (1 );
67+ this .selectRow (term);
68+ }
69+ },
70+ methods: {
71+ selectRow (rowId ) {
72+ this .selectedRow = rowId;
7173 },
72- };
73- </script >
74-
75- <!-- Add "scoped" attribute to limit CSS to this component only -->
76- <style scoped lang="scss">
77-
78- @import ' @/assets/style/routerLink.scss' ;
74+ },
75+ };
76+ </script >
7977
78+ <!-- Add "scoped" attribute to limit CSS to this component only -->
79+ <style scoped lang="scss">
8080@media only screen and (min-width : $desktop ) {
8181 .table-column-width {
8282 width : 30% !important ;
8585
8686.cve-term-active {
8787 background-color : $theme-color-accent-cool-light !important ;
88- color : black ;
89- padding-left : 8px ;
88+ color : black ;
89+ padding-left : 8px ;
9090 padding-top : 5px ;
9191 padding-bottom : 5px ;
9292}
93-
93+
9494.termLink {
9595 color : $theme-color-primary ;
96+ background : unset ;
97+ // scroll-margin: 50px;
9698}
9799
98100.selectTermLink {
99101 color : black ;
100102}
101103 </style >
102-
0 commit comments