diff --git a/package.json b/package.json index 1e75f6a..3db939f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "workspaces": [ "packages/*" ], - "description": "Web components to for accessing SPARQL endpoints.", + "description": "Web components for accessing SPARQL endpoints.", "license": "MIT", "author": { "name": "Vincent Emonet", @@ -14,7 +14,7 @@ }, "scripts": { "build": "npm run build:overview && npm run build:editor && npm run build:demo", - "dev": "npm run dev:editor", + "dev": "npm run build:overview && npm run dev:editor", "build:editor": "npm run build -w packages/sparql-editor", "dev:editor": "npm run dev -w packages/sparql-editor", "build:overview": "npm run build -w packages/sparql-overview", diff --git a/packages/demo/package.json b/packages/demo/package.json index a3c99d6..8cb9715 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -1,7 +1,7 @@ { - "name": "@sib-swiss/sparql-editor-demo", + "name": "@sib-swiss/sparql-demo", "version": "0.2.4", - "description": "A demo website of the SPARQL query editor. Built on the popular YASGUI editor, it provides context-aware autocomplete for classes and predicates based on the content of the endpoints.", + "description": "A demo website of the SPARQL tools.", "license": "MIT", "author": { "name": "Vincent Emonet", diff --git a/packages/demo/src/index.html b/packages/demo/src/index.html index 5a72bb4..9fc6f6e 100644 --- a/packages/demo/src/index.html +++ b/packages/demo/src/index.html @@ -30,7 +30,7 @@ diff --git a/packages/sparql-editor/src/sparql-editor.ts b/packages/sparql-editor/src/sparql-editor.ts index 41a0c64..f30024e 100644 --- a/packages/sparql-editor/src/sparql-editor.ts +++ b/packages/sparql-editor/src/sparql-editor.ts @@ -106,14 +106,14 @@ export class SparqlEditor extends HTMLElement { Add common prefixes Save query as example Browse examples - + Classes overview Clear cache `; - // TODO: Browse overview + // TODO: Browse overview this.appendChild(style); // NOTE: autocompleters are executed when Yasgui is instantiated @@ -204,7 +204,7 @@ export class SparqlEditor extends HTMLElement { Yasgui.Yasr.defaults.prefixes = this.meta[endpoint].prefixes; // Hide or show the Classes overview button - const clsOverviewBtn = this.querySelector("#sparql-cls-overview") as HTMLElement; + const clsOverviewBtn = this.querySelector("#sparql-cls-overview-btn") as HTMLElement; if (Object.keys(this.meta[endpoint].void).length > 0) { clsOverviewBtn.style.display = ""; } else { @@ -274,7 +274,10 @@ export class SparqlEditor extends HTMLElement { }); }); this.yasgui?.on("tabAdd", () => { - setTimeout(() => this.showExamples()); + setTimeout(() => { + this.showExamples(); + this.showOverview(); + }); }); // Button to clear and update cache of SPARQL endpoints metadata @@ -585,16 +588,14 @@ ex:${exampleUri} a sh:SPARQLExecutable${ } async showOverview() { - const overviewBtn = this.querySelector("#sparql-cls-overview") as HTMLButtonElement; - // Create dialog for examples + const overviewBtn = this.querySelector("#sparql-cls-overview-btn") as HTMLButtonElement; + const existingOverviewDialog = this.querySelector("#sparql-cls-overview-dialog") as HTMLDialogElement; + if (existingOverviewDialog) existingOverviewDialog.remove(); const overviewDialog = document.createElement("dialog"); - // exQueryDialog.style.margin = "1em"; - // exQueryDialog.style.width = "calc(100vw - 8px)"; + // Create dialog for overview + overviewDialog.id = "sparql-cls-overview-dialog"; overviewDialog.style.width = "100%"; overviewDialog.style.height = "100%"; - overviewDialog.style.borderColor = "#cccccc"; - overviewDialog.style.backgroundColor = "#f5f5f5"; - overviewDialog.style.borderRadius = "10px"; overviewDialog.innerHTML = ` `; @@ -607,13 +608,13 @@ ex:${exampleUri} a sh:SPARQLExecutable${ dialogCloseBtn.style.top = "1.5em"; dialogCloseBtn.style.right = "2em"; overviewDialog.appendChild(dialogCloseBtn); - document.body.appendChild(overviewDialog); + this.appendChild(overviewDialog); - overviewBtn.addEventListener("click", () => { - overviewDialog.showModal(); - document.body.style.overflow = "hidden"; - }); - overviewBtn.addEventListener("click", () => { + // Remove previous event listeners + overviewBtn.replaceWith(overviewBtn.cloneNode(true)); + const newOverviewBtn = this.querySelector("#sparql-cls-overview-btn") as HTMLButtonElement; + + newOverviewBtn.addEventListener("click", () => { overviewDialog.showModal(); document.body.style.overflow = "hidden"; }); diff --git a/packages/sparql-editor/src/styles.ts b/packages/sparql-editor/src/styles.ts index 0a508cc..238f632 100644 --- a/packages/sparql-editor/src/styles.ts +++ b/packages/sparql-editor/src/styles.ts @@ -7,88 +7,90 @@ // .yasr .dataTable { // font-size: 0.9em; // } -export const editorCss = `.sparql-editor-container a { - text-decoration: none; - color: #00709b; -} -.sparql-editor-container a:hover { - filter: brightness(60%); -} -.sparql-editor-container button { - cursor: pointer; -} -.sparql-editor-container { +export const editorCss = `.sparql-editor-container { + --btn-color: #e30613; + --btn-bg-color: #f8bca5; + font-family: Arial, sans-serif; display: flex; flex-direction: row; -} -.sparql-editor-container .sparql-examples { - padding-left: 1em; -} -.sparql-editor-container input.sparql-search-examples-input { - width: 300px; - padding: 0.5em; - border-radius: 5px; -} -@media (max-width: 600px) { - .sparql-editor-container { - flex-direction: column; + a { + text-decoration: none; + color: #00709b; } - .sparql-editor-container .sparql-examples { - display: none; + a:hover { + filter: brightness(60%); } - .sparql-editor-container #sparql-examples-top-btn { - display: inline-block; + dialog { + border-color: #cccccc; + background-color: #f5f5f5; + border-radius: 10px; } - .sparql-editor-container input.sparql-search-examples-input { - width: 100%; + .sparql-examples { + padding-left: 1em; } -} -@media (min-width: 600px) { - .sparql-editor-container #sparql-examples-top-btn { - display: none !important; + input.sparql-search-examples-input { + width: 300px; + padding: 0.5em; + border-radius: 5px; + } + .yasr_results { + overflow-x: auto; } -} - - -.sparql-editor-container { - --btn-color: #e30613; - --btn-bg-color: #f8bca5; - font-family: Arial, sans-serif; -} -.sparql-editor-container #status-link { + #status-link { display: inline-flex; justify-content: center; align-items: center; border-radius: 50%; cursor: pointer; padding: 3px; -} + } -@keyframes spin { - to { transform: rotate(360deg); } + button.btn { + background-color: var(--btn-bg-color); + color: var(--btn-color); + border: none; + padding: 0.3em 0.4em; + border-radius: 5px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Subtle shadow */ + cursor: pointer; + transition: background-color 0.3s ease, box-shadow 0.3s ease; + } + button.btn:hover { + filter: brightness(90%); + box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2); /* Larger shadow on hover */ + } + button.btn:active { + filter: brightness(80%); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Reset shadow on click */ + } } -.sparql-editor-container button.btn { - background-color: var(--btn-bg-color); - color: var(--btn-color); - border: none; - padding: 0.3em 0.4em; - border-radius: 5px; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Subtle shadow */ - cursor: pointer; - transition: background-color 0.3s ease, box-shadow 0.3s ease; -} -.sparql-editor-container button.btn:hover { - filter: brightness(90%); - box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2); /* Larger shadow on hover */ -} -.sparql-editor-container button.btn:active { - filter: brightness(80%); - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Reset shadow on click */ +@media (max-width: 600px) { + .sparql-editor-container { + flex-direction: column; + + .sparql-examples { + display: none; + } + #sparql-examples-top-btn { + display: inline-block; + } + input.sparql-search-examples-input { + width: 100%; + } + } +} +@media (min-width: 600px) { + .sparql-editor-container #sparql-examples-top-btn { + display: none !important; + } } +@keyframes spin { + to { transform: rotate(360deg); } +} button.yasqe_share { display: none !important; diff --git a/packages/sparql-overview/README.md b/packages/sparql-overview/README.md index be64c05..588d176 100644 --- a/packages/sparql-overview/README.md +++ b/packages/sparql-overview/README.md @@ -2,9 +2,9 @@ # ๐ซ SPARQL overview web component -[![NPM](https://img.shields.io/npm/v/@sib-swiss/sparql-metamap)](https://www.npmjs.com/package/@sib-swiss/sparql-metamap) -[![Tests](https://github.com/sib-swiss/sparql-metamap/actions/workflows/test.yml/badge.svg)](https://github.com/sib-swiss/sparql-metamap/actions/workflows/test.yml) -[![Deploy demo to GitHub Pages](https://github.com/sib-swiss/sparql-metamap/actions/workflows/deploy.yml/badge.svg)](https://github.com/sib-swiss/sparql-metamap/actions/workflows/deploy.yml) +[![NPM](https://img.shields.io/npm/v/@sib-swiss/sparql-overview)](https://www.npmjs.com/package/@sib-swiss/sparql-overview) +[![Tests](https://github.com/sib-swiss/sparql-editor/actions/workflows/test.yml/badge.svg)](https://github.com/sib-swiss/sparql-v/actions/workflows/test.yml) +[![Deploy demo to GitHub Pages](https://github.com/sib-swiss/sparql-editor/actions/workflows/deploy.yml/badge.svg)](https://github.com/sib-swiss/sparql-editor/actions/workflows/deploy.yml) @@ -12,34 +12,34 @@ A standard web component to visualize classes and their relations as a network. The editor retrieves VoID description about the endpoints by directly querying them with SPARQL. -๐๏ธ You can **try it** for a few SPARQL endpoints of the SIB, such as UniProt and Bgee, here: **[sib-swiss.github.io/sparql-metamap](https://sib-swiss.github.io/sparql-metamap)** +๐๏ธ You can **try it** for a few SPARQL endpoints of the SIB, such as UniProt and Bgee, here: **[sib-swiss.github.io/sparql-editor/overview](https://sib-swiss.github.io/sparql-editor/overview)** ## ๐ Use 1. Import from a CDN: ```html - + ``` Or install with a package manager in your project: ```bash - npm install --save @sib-swiss/sparql-metamap + npm install --save @sib-swiss/sparql-overview # or - pnpm add @sib-swiss/sparql-metamap + pnpm add @sib-swiss/sparql-overview ``` 2. Use the custom element in your HTML/JSX/TSX code: ```html - + ``` You can also pass a list of endpoints URLs separated by commas to enable users to choose from different endpoints: ```html - + ``` > [!WARNING] @@ -62,15 +62,12 @@ Create a `index.html` file with: - + - - About - This SPARQL endpoint contains... - +
This SPARQL endpoint contains...