From 3f81bcec054c6d04031951c10f3e303ad175a4f2 Mon Sep 17 00:00:00 2001 From: Le Minh Tri Date: Fri, 24 Feb 2023 15:18:57 +0700 Subject: [PATCH 1/3] feat(component): add component Icon --- src/components/Icon.astro | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/components/Icon.astro diff --git a/src/components/Icon.astro b/src/components/Icon.astro new file mode 100644 index 00000000..7eb44d7f --- /dev/null +++ b/src/components/Icon.astro @@ -0,0 +1,45 @@ +--- +import bi from '@iconify-json/bi/icons.json' +import type { HTMLAttributes } from 'astro/types' +import _get from 'lodash.get' + +export interface Props extends HTMLAttributes<'svg'> { + size?: number +} + +const { size = 16, ...props } = Astro.props + +const getIcon = (icon: string) => { + if (typeof icon !== 'string' || icon.length === 0) { + return '' + } + + const s = icon.split(':') + + if (s.length < 2) { + return '' + } + + const preset = s[0] + const iconName = s[1] + + if (preset !== 'bi') { + return '' + } + + return _get(bi.icons, `${iconName}.body`) +} + +const svg = getIcon(props.name || '') +--- + + From 3ba04a43894a23b75f7cdd300ac55e5cf64738c0 Mon Sep 17 00:00:00 2001 From: Le Minh Tri Date: Fri, 24 Feb 2023 15:20:49 +0700 Subject: [PATCH 2/3] build(dep): add package lodash.get --- package.json | 2 ++ pnpm-lock.yaml | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/package.json b/package.json index 1e197c4a..0087398c 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@commitlint/cli": "^17.4.4", "@commitlint/config-conventional": "^17.4.4", "@tailwindcss/typography": "^0.5.9", + "@types/lodash.get": "^4.4.7", "@types/node": "^18.14.0", "@typescript-eslint/eslint-plugin": "^5.53.0", "@typescript-eslint/parser": "^5.53.0", @@ -34,6 +35,7 @@ "eslint-plugin-astro": "^0.23.0", "eslint-plugin-simple-import-sort": "^10.0.0", "husky": "^8.0.3", + "lodash.get": "^4.4.2", "typescript": "^4.9.5" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 23154a62..dcbb092c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,7 @@ specifiers: '@commitlint/cli': ^17.4.4 '@commitlint/config-conventional': ^17.4.4 '@tailwindcss/typography': ^0.5.9 + '@types/lodash.get': ^4.4.7 '@types/node': ^18.14.0 '@typescript-eslint/eslint-plugin': ^5.53.0 '@typescript-eslint/parser': ^5.53.0 @@ -17,6 +18,7 @@ specifiers: eslint-plugin-astro: ^0.23.0 eslint-plugin-simple-import-sort: ^10.0.0 husky: ^8.0.3 + lodash.get: ^4.4.2 tailwindcss: ^3.0.24 typescript: ^4.9.5 @@ -31,6 +33,7 @@ devDependencies: '@commitlint/cli': 17.4.4 '@commitlint/config-conventional': 17.4.4 '@tailwindcss/typography': 0.5.9_tailwindcss@3.2.7 + '@types/lodash.get': 4.4.7 '@types/node': 18.14.0 '@typescript-eslint/eslint-plugin': 5.53.0_ny4s7qc6yg74faf3d6xty2ofzy '@typescript-eslint/parser': 5.53.0_7kw3g6rralp5ps6mg3uyzz6azm @@ -40,6 +43,7 @@ devDependencies: eslint-plugin-astro: 0.23.0_eslint@8.34.0 eslint-plugin-simple-import-sort: 10.0.0_eslint@8.34.0 husky: 8.0.3 + lodash.get: 4.4.2 typescript: 4.9.5 packages: @@ -984,6 +988,16 @@ packages: resolution: {integrity: sha512-sqm9g7mHlPY/43fcSNrCYfOeX9zkTTK+euO5E6+CVijSMm5tTjkVdwdqRkY3ljjIAf8679vps5jKUoJBCLsMDA==} dev: false + /@types/lodash.get/4.4.7: + resolution: {integrity: sha512-af34Mj+KdDeuzsJBxc/XeTtOx0SZHZNLd+hdrn+PcKGQs0EG2TJTzQAOTCZTgDJCArahlCzLWSy8c2w59JRz7Q==} + dependencies: + '@types/lodash': 4.14.191 + dev: true + + /@types/lodash/4.14.191: + resolution: {integrity: sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==} + dev: true + /@types/mdast/3.0.10: resolution: {integrity: sha512-W864tg/Osz1+9f4lrGTZpCSO5/z4608eUp19tbozkq2HJK6i3z1kT0H9tlADXuYIb1YYOBByU4Jsqkk75q48qA==} dependencies: @@ -3261,6 +3275,10 @@ packages: resolution: {integrity: sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==} dev: true + /lodash.get/4.4.2: + resolution: {integrity: sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==} + dev: true + /lodash.isfunction/3.0.9: resolution: {integrity: sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw==} dev: true From 1576b66bdd28b77a44fc27bf1592ccb4e379db25 Mon Sep 17 00:00:00 2001 From: Le Minh Tri Date: Fri, 24 Feb 2023 15:23:39 +0700 Subject: [PATCH 3/3] build(dep): add package @iconify-json/bi --- package.json | 1 + pnpm-lock.yaml | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/package.json b/package.json index 0087398c..be3f420c 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "devDependencies": { "@commitlint/cli": "^17.4.4", "@commitlint/config-conventional": "^17.4.4", + "@iconify-json/bi": "^1.1.15", "@tailwindcss/typography": "^0.5.9", "@types/lodash.get": "^4.4.7", "@types/node": "^18.14.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dcbb092c..2edb9b2e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,7 @@ specifiers: '@astrojs/tailwind': ^3.0.1 '@commitlint/cli': ^17.4.4 '@commitlint/config-conventional': ^17.4.4 + '@iconify-json/bi': ^1.1.15 '@tailwindcss/typography': ^0.5.9 '@types/lodash.get': ^4.4.7 '@types/node': ^18.14.0 @@ -32,6 +33,7 @@ dependencies: devDependencies: '@commitlint/cli': 17.4.4 '@commitlint/config-conventional': 17.4.4 + '@iconify-json/bi': 1.1.15 '@tailwindcss/typography': 0.5.9_tailwindcss@3.2.7 '@types/lodash.get': 4.4.7 '@types/node': 18.14.0 @@ -802,6 +804,16 @@ packages: resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} dev: true + /@iconify-json/bi/1.1.15: + resolution: {integrity: sha512-NsbDeTVIYwgPLyAT0UgzuaCl79V65Z+M319BjbdEwdnbDGuaYgmAMBJUIWrnBEVoEg7rtouAuvaZRb3nIYIRcA==} + dependencies: + '@iconify/types': 2.0.0 + dev: true + + /@iconify/types/2.0.0: + resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} + dev: true + /@jridgewell/gen-mapping/0.1.1: resolution: {integrity: sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==} engines: {node: '>=6.0.0'}