diff --git a/.gitignore b/.gitignore index ad1b1f4..5989668 100644 --- a/.gitignore +++ b/.gitignore @@ -86,7 +86,6 @@ out # Nuxt.js build / generate output .nuxt -dist # Gatsby files .cache/ @@ -204,7 +203,6 @@ out # Nuxt.js build / generate output .nuxt -dist # Gatsby files .cache/ @@ -237,3 +235,4 @@ dist .yarn/install-state.gz .pnp.* +/.trash/ diff --git a/package.json b/package.json index 9d48e6f..d57c51f 100644 --- a/package.json +++ b/package.json @@ -9,21 +9,29 @@ "srv": "cross-env SOURCE_MAP_ENV=true webpack serve", "watch": "webpack --watch", "build": "cross-env NODE_ENV=production webpack", - "build-dev": "cross-env SOURCE_MAP_ENV=true webpack" + "build-dev": "cross-env SOURCE_MAP_ENV=true NODE_ENV=production webpack" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "@babel/core": "^7.15.5", + "@babel/plugin-proposal-class-properties": "^7.14.5", "@babel/preset-env": "^7.15.6", "babel-loader": "^8.2.2", "clean-webpack-plugin": "^4.0.0", "cross-env": "^7.0.3", "css-loader": "^6.3.0", + "css-minimizer-webpack-plugin": "^3.1.1", + "css-mqpacker-webpack-plugin": "^0.12.1", + "glob": "^7.2.0", "html-webpack-plugin": "^5.3.2", "mini-css-extract-plugin": "^2.3.0", - "terser-webpack-plugin": "^5.2.4", + "mini-svg-data-uri": "^1.3.3", + "postcss-loader": "^6.1.1", + "postcss-preset-env": "^6.7.0", + "purgecss-webpack-plugin": "^4.0.3", + "style-loader": "^3.3.0", "webpack": "^5.56.1", "webpack-cli": "^4.8.0", "webpack-dev-server": "^4.3.1" diff --git a/src/env.json b/src/env.json index cde9308..4510c06 100644 --- a/src/env.json +++ b/src/env.json @@ -9,6 +9,7 @@ ], "querySelectors": { "console": "#appConsole", + "navTabs": "#asSwitcher", "modal": ".modal", "notesGrid": "#notesGrid", "noteEditForm": "#noteEditForm", @@ -22,8 +23,8 @@ }, "gridOrder": { "notes": [ - "title", "createdAt", + "title", "category", "content", "dates", diff --git a/src/helpers.js b/src/helpers.js new file mode 100644 index 0000000..32a69d9 --- /dev/null +++ b/src/helpers.js @@ -0,0 +1,80 @@ +export const env = require('./env.json') +export const msgBox = document.getElementById(env.querySelectors.console.slice(1)) + +/** + * + * @type {{}} + */ +const monthsNamesFull = env.lists.monthsFull + +/** + * + * @param string + * @returns {string} + */ +export const ucWords = string => { + return string.split('_').map(word => word.charAt(0).toUpperCase() + word.substr(1).toLowerCase()).join(' ') +} + + +/** + * + * @param date + * @returns {string} + */ +export const formatDate = date => { + const dt = new Date(date) + return [monthsNamesFull[dt.getMonth()], dt.getDate(), `, ${dt.getFullYear()}`].join(' ') +} + +/** + * + * @param str + * @returns {*[]} + */ +export const findDates = str => { + const dates = [] + const regex = new RegExp('[0-3]?[0-9].[0-3]?[0-9].(?:[0-9]{2})?[0-9]{2}', 'mg') + + for (const match of (str || '').matchAll(regex)) { + dates.push(match[0]) + } + + return dates +} + +/** + * + * @param args + * @returns {*} + */ +export const createNode = (...args) => { + const [tag, attrs, content, callback] = args + const node = document.createElement(tag) + + for (const [key, value] of Object.entries(attrs || [])) { + node.setAttribute(key, value) + } + + node.innerHTML = content || '' + + return node +} + +/** + * + * @param node + */ +export const destroyNode = (node) => { + + if (!(node instanceof Node) && typeof node === 'string') { + node = document.querySelector(node) + } + + try { + node.remove() + } catch (e) {} + +} + + diff --git a/src/index.html b/src/index.html index 0454386..7d95e6a 100644 --- a/src/index.html +++ b/src/index.html @@ -8,6 +8,5 @@
-