Skip to content

Commit

Permalink
Added icon source links, and attribution in readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioCasCeb committed Jan 19, 2024
1 parent 047264b commit d45f2f3
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 390 deletions.
21 changes: 15 additions & 6 deletions packages/web-new/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ This package provides the new web interface of the Web of Things Playground. It

Licensed under the MIT license, see [License](../../LICENSE.md).

## Icon

Icons used in this project (excluding the TD file icon) are sourced from FontAwesome Free 6.5.1 by @fontawesome - [FontAwesome](https://fontawesome.com).
License information can be found here: [FontAwesome License](https://fontawesome.com/license/free). Copyright © 2024 Fonticons, Inc.

## How to use

- Online: It is hosted [here](http://plugfest.thingweb.io/playground-new/)
- Simply paste a TD or utilize an example from the examples menu and click on validate
- The validation process will then start on the bottom console, where more information will be provided in case of errors or warnings

## Testing with Playwright

## Webpack functionality and bundling

This package is built by utilizing webpack, allowing to bundle and compile the projects JavaScript and CSS files. It also handles asset management and optimization. Below are the steps to understand the current configuration:
Expand All @@ -50,27 +53,33 @@ The `webpack.config.js` file is used to set up Webpack for the project. It manag
### 3. Webpack Configuration Obejct

**3.1 Entry Points**

- `entry`: Specifies the entry points for your application. In this case, there are two entry points: 'bundle' for JavaScript and 'styles' for CSS

**3.2 Output**

- `output`: Specifies where Webpack should output the bundled files. The path property defines the output directory as 'dist', and the filename property determines the naming pattern for generated files. [name] is a placeholder for the entry point name, and [contenthash] is a unique hash based on file content
- `clean`: Tells Webpack to clean the 'dist' directory before each build
- `assetModuleFilename`: Specifies the filename for asset files

**3.3 Development Server**

- `devServer`: Configures the development server with settings such as the port, compressing assets, and enabling history API fallback

**3.4 Module Rules**

- `module`: Defines rules for how Webpack should process different file types. There are rules for JavaScript, images, CSS, and more. For example, it uses Babel to transpile JavaScript, handles image assets, and processes CSS with style loaders and sass loaders

**3.5 Plugins**
- `plugins`: Lists the plugins used in the build process. Key plugins include
- `HtmlWebpackPlugin` for generating HTML files,
- `CopyWebpackPlugin` for copying assets,
- `MonacoWebpackPlugin` for the Monaco code editor integration, and

- `plugins`: Lists the plugins used in the build process. Key plugins include
- `HtmlWebpackPlugin` for generating HTML files,
- `CopyWebpackPlugin` for copying assets,
- `MonacoWebpackPlugin` for the Monaco code editor integration, and
- `MiniCssExtractPlugin` for extracting CSS into separate files

**3.6 Optimization**

- `optimization`: Contains settings for optimizing the build, including minimizing CSS using `CssMinimizerPlugin`


Expand Down
16 changes: 9 additions & 7 deletions packages/web-new/src/scripts/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ import { textIcon } from './main.js'
//Main console elements
const errorContainer = document.querySelector(".console__content #console-error")
const errorTxt = document.querySelector(".console-error__txt")
const minMaxBtn = document.querySelector(".min-max")
export const collapseArrows = minMaxBtn.querySelector(".collapse-arrows")
export const expandArrows = minMaxBtn.querySelector(".expand-arrows")
export const minMaxBtn = document.querySelector(".min-max")
export const visualizationOptions = document.querySelectorAll(".visualizations__option")
export const visualizationContainers = document.querySelectorAll(".console-view")
export const consoleElement = document.querySelector(".console")
Expand All @@ -48,6 +46,7 @@ const mainContentElement = document.querySelector(".main-content")
/**
* Hides the text from the left control panel, updates the state of the console element
* and adjusts the console size as well as the expand/collapse icon
* *Collapse arrows gotten from: https://fontawesome.com/icons/down-left-and-up-right-to-center?f=classic&s=solid
*/
function expandConsole() {
textIcon.forEach(text => {
Expand All @@ -60,14 +59,16 @@ function expandConsole() {
setTimeout(() => {
mainContentElement.style.flex = "0 210px"
consoleElement.style.flex = `1 0`
collapseArrows.classList.remove("hidden")
expandArrows.classList.add("hidden")
minMaxBtn.children[0].children[0].setAttribute("d", "M439 7c9.4-9.4 24.6-9.4 33.9 0l32 32c9.4 9.4 9.4 24.6 0 33.9l-87 87 39 39c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8H296c-13.3 0-24-10.7-24-24V72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2l39 39L439 7zM72 272H216c13.3 0 24 10.7 24 24V440c0 9.7-5.8 18.5-14.8 22.2s-19.3 1.7-26.2-5.2l-39-39L73 505c-9.4 9.4-24.6 9.4-33.9 0L7 473c-9.4-9.4-9.4-24.6 0-33.9l87-87L55 313c-6.9-6.9-8.9-17.2-5.2-26.2s12.5-14.8 22.2-14.8z")
minMaxBtn.children[0].classList.remove("expand-arrows")
minMaxBtn.children[0].classList.add("collapse-arrows")
}, 100);
}

/**
* Shows the text from the left control panel, updates the state of the console element
* and adjusts the console size as well as the expand/collapse icon
* *Expand arrows gotten from: https://fontawesome.com/icons/up-right-and-down-left-from-center?f=classic&s=solid
*/
function collapseConsole() {
textIcon.forEach(text => {
Expand All @@ -79,8 +80,9 @@ function collapseConsole() {

mainContentElement.style.flex = "1 0"
consoleElement.style.flex = `0 39px`
collapseArrows.classList.add("hidden")
expandArrows.classList.remove("hidden")
minMaxBtn.children[0].children[0].setAttribute("d", "M344 0H488c13.3 0 24 10.7 24 24V168c0 9.7-5.8 18.5-14.8 22.2s-19.3 1.7-26.2-5.2l-39-39-87 87c-9.4 9.4-24.6 9.4-33.9 0l-32-32c-9.4-9.4-9.4-24.6 0-33.9l87-87L327 41c-6.9-6.9-8.9-17.2-5.2-26.2S334.3 0 344 0zM168 512H24c-13.3 0-24-10.7-24-24V344c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2l39 39 87-87c9.4-9.4 24.6-9.4 33.9 0l32 32c9.4 9.4 9.4 24.6 0 33.9l-87 87 39 39c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8z")
minMaxBtn.children[0].classList.add("expand-arrows")
minMaxBtn.children[0].classList.remove("collapse-arrows")
}

minMaxBtn.addEventListener("click", () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/web-new/src/scripts/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function createTab(tabNumber, exampleName, thingType) {
closeBtn.classList.add("close-tab")

// Create the svg close icon
// Close icon gotten from: https://fontawesome.com/icons/xmark?f=classic&s=solid
const closeIconSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg")
closeIconSvg.setAttribute("xmlns", "http://www.w3.org/2000/svg")
closeIconSvg.setAttribute("width", "100%")
Expand All @@ -120,7 +121,9 @@ function createTab(tabNumber, exampleName, thingType) {
const confirmTabClose = document.createElement("button")
confirmTabClose.classList.add("confirm-tab-close")
confirmTabClose.textContent = "Close"

// Create the svg confirm close icon
// Check icon gotten from: https://fontawesome.com/icons/check?f=classic&s=solid
const confirmIconSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg")
confirmIconSvg.setAttribute("xmlns", "http://www.w3.org/2000/svg")
confirmIconSvg.setAttribute("width", "100%")
Expand All @@ -145,6 +148,7 @@ function createTab(tabNumber, exampleName, thingType) {
cancelTabClose.textContent = "Cancel"

// Create the svg close cancel icon
// Close icon gotten from: https://fontawesome.com/icons/xmark?f=classic&s=solid
const cancelIconSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg")
cancelIconSvg.setAttribute("xmlns", "http://www.w3.org/2000/svg")
cancelIconSvg.setAttribute("width", "100%")
Expand Down
6 changes: 2 additions & 4 deletions packages/web-new/src/scripts/examples-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,6 @@ async function getAllExamples(categoryId, thingType) {
tdFilePath.setAttribute("clip-rule", "evenodd")
tdFilePath.setAttribute("d", "M184 0V95.9981C184 107.044 192.954 115.998 204 115.998H300V190H106C89.4315 190 76 203.431 76 220V379H40C17.9086 379 0 361.091 0 339V40C0 17.9086 17.9086 0 40 0H184ZM204 95.9981V4.28427L295.714 95.9981H204ZM189.758 379V265.724H231.32V243.922H189.758H162.019H121.105V265.724H162.019V379H189.758ZM275.017 379H288.654C297.808 379 306.158 377.485 313.703 374.454C321.311 371.362 327.836 367.001 333.278 361.373C338.783 355.683 343.02 348.88 345.988 340.963C349.019 333.046 350.534 324.295 350.534 314.708V308.307C350.534 298.658 349.019 289.907 345.988 282.052C343.02 274.135 338.783 267.332 333.278 261.642C327.774 255.951 321.249 251.591 313.703 248.561C306.219 245.468 297.963 243.922 288.933 243.922H275.017H258.688H247.185V379H259.245H275.017ZM275.017 357.291H288.654C295.952 357.291 302.106 355.652 307.116 352.374C312.126 349.034 315.899 344.179 318.435 337.809C321.032 331.438 322.331 323.738 322.331 314.708V308.121C322.331 301.194 321.589 295.102 320.104 289.845C318.682 284.588 316.548 280.165 313.703 276.578C310.858 272.991 307.364 270.3 303.22 268.507C299.076 266.651 294.313 265.724 288.933 265.724H275.017V357.291Z")

//Create and append Font Awesome attribution comment
const commentTDFile = document.createComment(" !Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc. ")
tdFileSvg.appendChild(commentTDFile)

// Append the path element to the SVG element
tdFileSvg.appendChild(tdFilePath)

Expand All @@ -300,6 +296,7 @@ async function getAllExamples(categoryId, thingType) {
exampleName.appendChild(exampleNameTitle)

//Create, populate and append the example title toggle arrow
// Arrow icon gotten from: https://fontawesome.com/icons/angle-down?f=classic&s=solid
const exampleArrowSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg")
exampleArrowSvg.setAttribute("xmlns", "http://www.w3.org/2000/svg")
exampleArrowSvg.setAttribute("width", "100%")
Expand Down Expand Up @@ -362,6 +359,7 @@ async function getAllExamples(categoryId, thingType) {
exampleBtns.appendChild(exampleBtnUse)

// create the svg icon for the apply button
// Apply icon gotten from: https://fontawesome.com/icons/file-import?f=classic&s=solid
const applyIconSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg")
applyIconSvg.setAttribute("xmlns", "http://www.w3.org/2000/svg")
applyIconSvg.setAttribute("width", "100%")
Expand Down
16 changes: 9 additions & 7 deletions packages/web-new/src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import './json-yaml'
import './settings-menu'
import './save-menu'
import './examples-menu'
import { consoleElement, expandArrows, collapseArrows } from './console'
import { consoleElement, minMaxBtn } from './console'
import './open-api'
import './async-api'
import './aas'
Expand Down Expand Up @@ -165,12 +165,13 @@ function onmousemoveY(e) {
b.style.flex = `0 ${h < 50 ? 39 : h}px`
t.style.flex = "1 0"

if(h < 39){
if (h < 39) {
consoleElement.classList.remove("expanded")
consoleElement.classList.add("collapsed")

collapseArrows.classList.add("hidden")
expandArrows.classList.remove("hidden")
minMaxBtn.children[0].children[0].setAttribute("d", "M344 0H488c13.3 0 24 10.7 24 24V168c0 9.7-5.8 18.5-14.8 22.2s-19.3 1.7-26.2-5.2l-39-39-87 87c-9.4 9.4-24.6 9.4-33.9 0l-32-32c-9.4-9.4-9.4-24.6 0-33.9l87-87L327 41c-6.9-6.9-8.9-17.2-5.2-26.2S334.3 0 344 0zM168 512H24c-13.3 0-24-10.7-24-24V344c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2l39 39 87-87c9.4-9.4 24.6-9.4 33.9 0l32 32c9.4 9.4 9.4 24.6 0 33.9l-87 87 39 39c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8z")
minMaxBtn.children[0].classList.add("expand-arrows")
minMaxBtn.children[0].classList.remove("collapse-arrows")
}

if (h < 445) {
Expand All @@ -185,12 +186,13 @@ function onmousemoveY(e) {
t.style.flex = `0 ${h < 220 ? 210 : h}px`
b.style.flex = "1 0"

if ( h > 714 ){
if (h > 714) {
consoleElement.classList.remove("collapsed")
consoleElement.classList.add("expanded")

expandArrows.classList.add("hidden")
collapseArrows.classList.remove("hidden")
minMaxBtn.children[0].children[0].setAttribute("d", "M439 7c9.4-9.4 24.6-9.4 33.9 0l32 32c9.4 9.4 9.4 24.6 0 33.9l-87 87 39 39c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8H296c-13.3 0-24-10.7-24-24V72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2l39 39L439 7zM72 272H216c13.3 0 24 10.7 24 24V440c0 9.7-5.8 18.5-14.8 22.2s-19.3 1.7-26.2-5.2l-39-39L73 505c-9.4 9.4-24.6 9.4-33.9 0L7 473c-9.4-9.4-9.4-24.6 0-33.9l87-87L55 313c-6.9-6.9-8.9-17.2-5.2-26.2s12.5-14.8 22.2-14.8z")
minMaxBtn.children[0].classList.remove("expand-arrows")
minMaxBtn.children[0].classList.add("collapse-arrows")
}

if (h < 310) {
Expand Down
Loading

0 comments on commit d45f2f3

Please sign in to comment.