Skip to content

Commit

Permalink
Merge branch 'dev' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
SteelWagstaff committed Jun 1, 2023
2 parents ceb73ab + 0be541d commit c4c1754
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- name: Run e2e tests
if: steps.code-changes.outputs.changed == 'true'
uses: cypress-io/github-action@v5.7.2
uses: cypress-io/github-action@v5.8.0
with:
start: npm run dev
wait-on: http://localhost:3001
Expand Down
8 changes: 8 additions & 0 deletions e2e/integration/bookCards.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ describe('Book cards', function () {
.first()
.should('include.text','Written specifically for students in Boise State University’s Bachelor of Applied Science');
});
it('Search a book with a link within the description and check if it is rendered', () => {
search('Advanced Professional Communication');
cy.get(Elements.bookCards.description)
.first()
.should('include.text','supports the learning outcomes')
.contains('a', 'open textbook')
.should('have.attr', 'href', 'https://google.com#anchor1');
});
it('Check all book card attributes from a particular book', () => {
const attributesToCheck = [
{
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pressbooks-directory",
"version": "2.9.0",
"version": "2.9.1",
"type": "module",
"engines": {
"node": ">=16.0.0"
Expand Down Expand Up @@ -45,8 +45,8 @@
"cypress": "^12.12.0",
"cypress-wait-until": "^1.7.2",
"eslint": "^8.41.0",
"eslint-plugin-vue": "^9.14.0",
"postcss": "^8.4.23",
"eslint-plugin-vue": "^9.14.1",
"postcss": "^8.4.24",
"postcss-nested": "^6.0.1",
"tailwindcss": "^3.3.2",
"vite": "^3.2.6",
Expand Down
36 changes: 18 additions & 18 deletions src/components/VueClamp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,9 @@ export default defineComponent({
this.localExpanded = !this.localExpanded;
},
getLines() {
return Object.keys(
Array.prototype.slice
.call(this.$refs.content.getClientRects())
.reduce((prev, { top, bottom }) => {
const key = `${top}/${bottom}`;
if (!prev[key]) {
prev[key] = true;
}
return prev;
}, {})
).length;
const lineHeight = parseInt(getComputedStyle(this.$refs.content).lineHeight);
const contentHeight = this.$refs.content.offsetHeight;
return Math.round(contentHeight / lineHeight);
},
isOverflow() {
if (!this.maxLines && !this.maxHeight) {
Expand All @@ -184,11 +176,17 @@ export default defineComponent({
return false;
},
getText() {
// Look for the first non-empty text node
const [content] = (this.$slots.default() || []).filter(
(node) => !node.tag && !node.isComment
);
return content ? content.children : '';
const contents = this.$slots.default ? this.$slots.default() : [];
let text = '';
for (let i = 0; i < contents.length; i++) {
const node = contents[i];
if (!node.tag && !node.isComment && node.children) {
text += Array.isArray(node.children)
? node.children.join('')
: [...node.children].join('');
}
}
return text;
},
moveEdge(steps) {
this.clampAt(this.offset + steps);
Expand All @@ -198,7 +196,7 @@ export default defineComponent({
this.applyChange();
},
applyChange() {
this.$refs.text.textContent = this.realText;
this.$refs.text.innerHTML = this.realText;
},
stepToFit() {
this.fill();
Expand Down Expand Up @@ -246,8 +244,10 @@ export default defineComponent({
attrs: {
'aria-label': this.text?.trim(),
},
class: 'book-description',
innerHTML: this.realText,
},
this.realText
[]
),
];
Expand Down
2 changes: 1 addition & 1 deletion src/components/books/PbBooks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default {
return helpers.functions.getLicenseIconAndAltByLicenseName(item.licenseName);
},
removeXMLTags(string) {
return string.replace(/(<([^>]+)>)/gi, '');
return string.replace(/(<\/?(?:a|p|em|strong|ul|ol|li|u|span)[^>]*>)|<[^>]+>/ig, '$1');
},
getBookDescription(item) {
if (!item.hasDescription && item.hasDisambiguatingDescription) {
Expand Down
4 changes: 4 additions & 0 deletions src/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ ul#footer-menu > li {
font-weight: 400;
font-size: 14px;
color: black;
}

.book-description a {
@apply text-pb-red underline;
}

0 comments on commit c4c1754

Please sign in to comment.