Skip to content

Commit

Permalink
Enable opening links defined in item
Browse files Browse the repository at this point in the history
  • Loading branch information
bas080 committed Jun 26, 2024
1 parent 29982ef commit 9e78dc2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
15 changes: 15 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"description": "",
"dependencies": {
"js-levenshtein": "^1.1.6",
"linkify-string": "^4.1.3",
"linkifyjs": "^4.1.3",
"lit-html": "^3.1.4",
"qrcode-svg": "^1.1.0",
"unique-names-generator": "^4.7.1"
Expand Down
7 changes: 7 additions & 0 deletions straw/closed/enable_opening_links_defined_in_item.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Enable opening links defined in item

As a user
I want to click on URL-like strings
So that I can open links directly from the text.

#feature
11 changes: 10 additions & 1 deletion toplist.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { html, render } from "lit-html";
import { unsafeHTML } from "lit-html/directives/unsafe-html.js";
import linkify from "linkify-string";
import emojiMap from "./emoji.json";
import levenshtein from "js-levenshtein";
import { version } from "./package.json";
Expand Down Expand Up @@ -132,7 +134,14 @@ const onListItemClick = (value, isTopList, index) => (event) => {
const listItem = (isTopList) => (value, index) =>
html` <li class="list-item">
<form @submit=${onListItemClick(value, isTopList, index)}>
<button>${value} ${someEmoji(value)}</button>
<button>
${unsafeHTML(
linkify(value, {
target: "_blank",
}),
)}
${someEmoji(value)}
</button>
</form>
</li>`;

Expand Down

0 comments on commit 9e78dc2

Please sign in to comment.