Преглед изворни кода

Merge pull request #8356 from weseek/feat/136288-136767-icon-package

feat: Build GROWI custom icons
yuken пре 2 година
родитељ
комит
aee002218d

+ 1 - 0
apps/app/package.json

@@ -68,6 +68,7 @@
     "@elastic/elasticsearch8": "npm:@elastic/elasticsearch@^8.7.0",
     "@elastic/elasticsearch8": "npm:@elastic/elasticsearch@^8.7.0",
     "@godaddy/terminus": "^4.9.0",
     "@godaddy/terminus": "^4.9.0",
     "@google-cloud/storage": "^5.8.5",
     "@google-cloud/storage": "^5.8.5",
+    "@growi/custom-icons": "link:../../packages/custom-icons",
     "@growi/core": "link:../../packages/core",
     "@growi/core": "link:../../packages/core",
     "@growi/pluginkit": "link:../../packages/pluginkit",
     "@growi/pluginkit": "link:../../packages/pluginkit",
     "@growi/preset-templates": "link:../../packages/preset-templates",
     "@growi/preset-templates": "link:../../packages/preset-templates",

+ 3 - 1
apps/app/src/components/FontFamily/GlobalFonts.tsx

@@ -1,5 +1,6 @@
 import { memo } from 'react';
 import { memo } from 'react';
 
 
+import { useGrowiCustomIcon } from './use-growi-custom-icons';
 import { useLatoFontFamily } from './use-lato';
 import { useLatoFontFamily } from './use-lato';
 import { useMaterialSymbolsOutlined } from './use-material-symbols-outlined';
 import { useMaterialSymbolsOutlined } from './use-material-symbols-outlined';
 import { useSourceHanCodeJP } from './use-source-han-code-jp';
 import { useSourceHanCodeJP } from './use-source-han-code-jp';
@@ -8,16 +9,17 @@ import { useSourceHanCodeJP } from './use-source-han-code-jp';
  * Define prefixed by '--grw-font-family'
  * Define prefixed by '--grw-font-family'
  */
  */
 export const GlobalFonts = memo((): JSX.Element => {
 export const GlobalFonts = memo((): JSX.Element => {
-
   const latoFontFamily = useLatoFontFamily();
   const latoFontFamily = useLatoFontFamily();
   const sourceHanCodeJPFontFamily = useSourceHanCodeJP();
   const sourceHanCodeJPFontFamily = useSourceHanCodeJP();
   const materialSymbolsOutlinedFontFamily = useMaterialSymbolsOutlined();
   const materialSymbolsOutlinedFontFamily = useMaterialSymbolsOutlined();
+  const customSvgFontFamily = useGrowiCustomIcon();
 
 
   return (
   return (
     <>
     <>
       {latoFontFamily}
       {latoFontFamily}
       {sourceHanCodeJPFontFamily}
       {sourceHanCodeJPFontFamily}
       {materialSymbolsOutlinedFontFamily}
       {materialSymbolsOutlinedFontFamily}
+      {customSvgFontFamily}
     </>
     </>
   );
   );
 });
 });

+ 17 - 0
apps/app/src/components/FontFamily/use-growi-custom-icons.tsx

@@ -0,0 +1,17 @@
+import localFont from 'next/font/local';
+
+import { DefineStyle } from './types';
+
+const growiCustomIconFont = localFont({
+  src: '../../../../../packages/custom-icons/dist/growi-custom-icons.woff2',
+});
+
+export const useGrowiCustomIcon: DefineStyle = () => (
+  <style jsx global>
+    {`
+      :root {
+        --grw-font-family-custom-icon: ${growiCustomIconFont.style.fontFamily};
+      }
+    `}
+  </style>
+);

+ 0 - 25
apps/app/src/components/Me/SidebarCollapsedIcon.jsx

@@ -1,25 +0,0 @@
-import React from 'react';
-
-const SidebarCollapsedIcon = () => (
-  <svg
-    xmlns="http://www.w3.org/2000/svg"
-    viewBox="0 0 23 23"
-  >
-    <rect width="23" height="23" fillOpacity="0" />
-    <path d="M20.9,3.9c0.3,0,0.6,0.3,0.6,0.6v13.9c0,0.3-0.3,0.6-0.6,0.6H2.1c-0.3,0-0.6-0.3-0.6-0.6V4.5c0-0.3,0.3-0.6,0.6-0.6H20.9
-      M20.9,2.4H2.1C1,2.4,0,3.4,0,4.5c0,0,0,0,0,0v13.9c0,1.2,1,2.1,2.1,2.1c0,0,0,0,0,0h18.7c1.2,0,2.1-0.9,2.1-2.1c0,0,0,0,0,0V4.5
-      C23,3.4,22,2.4,20.9,2.4C20.9,2.4,20.9,2.4,20.9,2.4z"
-    />
-    <rect x="7.5" y="3.9" width="1.2" height="0.8" />
-    <rect x="7.5" y="15.3" width="1.2" height="1.5" />
-    <rect x="7.5" y="12.3" width="1.2" height="1.5" />
-    <rect x="7.5" y="9.2" width="1.2" height="1.6" />
-    <rect x="7.5" y="6.1" width="1.2" height="1.6" />
-    <rect x="7.5" y="18.4" width="1.2" height="0.8" />
-    <path d="M15.1,14.9c-0.2,0-0.3-0.1-0.4-0.2l-2.8-2.8c-0.2-0.2-0.2-0.6,0-0.8l2.8-2.8c0.2-0.2,0.6-0.2,0.9,0s0.2,0.6,0,0.9l-2.4,2.4
-      l2.4,2.4c0.2,0.2,0.2,0.6,0,0.9C15.4,14.8,15.3,14.9,15.1,14.9z"
-    />
-  </svg>
-);
-
-export default SidebarCollapsedIcon;

+ 0 - 20
apps/app/src/components/Me/SidebarDockIcon.jsx

@@ -1,20 +0,0 @@
-import React from 'react';
-
-const SidebarDockIcon = () => (
-  <svg
-    xmlns="http://www.w3.org/2000/svg"
-    viewBox="0 0 23 23"
-  >
-    <rect width="23" height="23" fillOpacity="0" />
-    <path
-      d="M20.86,3.92a.64.64,0,0,1,.64.63v13.9a.64.64,0,0,1-.64.63H2.14a.64.64,0,0,
-      1-.64-.63V4.55a.64.64,0,0,1,.64-.63H20.86m0-1.5H2.14A2.13,2.13,0,0,0,0,4.55v13.9a2.13,
-      2.13,0,0,0,2.14,2.13H20.86A2.13,2.13,0,0,0,23,18.45V4.55a2.13,2.13,0,0,0-2.14-2.13Z"
-    />
-    <rect x="7.49" y="3.05" width="1.2" height="16.91" />
-  </svg>
-
-);
-
-
-export default SidebarDockIcon;

+ 2 - 0
apps/app/src/components/Me/UISettings.module.scss

@@ -1,6 +1,8 @@
 @use '@growi/core/scss/bootstrap/init' as bs;
 @use '@growi/core/scss/bootstrap/init' as bs;
 
 
 .grw-sidebar-mode-icon {
 .grw-sidebar-mode-icon {
+  display: flex;
+  align-items: center;
   width: 20px;
   width: 20px;
   height: 20px;
   height: 20px;
   color: bs.$secondary;
   color: bs.$secondary;

+ 3 - 6
apps/app/src/components/Me/UISettings.tsx

@@ -7,9 +7,6 @@ import { updateUserUISettings } from '~/client/services/user-ui-settings';
 import { toastError, toastSuccess } from '~/client/util/toastr';
 import { toastError, toastSuccess } from '~/client/util/toastr';
 import { useCollapsedContentsOpened, usePreferCollapsedMode, useSidebarMode } from '~/stores/ui';
 import { useCollapsedContentsOpened, usePreferCollapsedMode, useSidebarMode } from '~/stores/ui';
 
 
-import SidebarCollapsedIcon from './SidebarCollapsedIcon';
-import SidebarDockIcon from './SidebarDockIcon';
-
 import styles from './UISettings.module.scss';
 import styles from './UISettings.module.scss';
 
 
 const IconWithTooltip = ({
 const IconWithTooltip = ({
@@ -60,9 +57,9 @@ export const UISettings = (): JSX.Element => {
               label="Collapsed"
               label="Collapsed"
               additionalClasses={styles['grw-sidebar-mode-icon']}
               additionalClasses={styles['grw-sidebar-mode-icon']}
             >
             >
-              <SidebarCollapsedIcon />
+              <span className="growi-custom-icons">sidebar-collapsed</span>
             </IconWithTooltip>
             </IconWithTooltip>
-            <div className="form-check form-switch ms-2">
+            <div className="form-check form-switch ms-1">
 
 
               <input
               <input
                 id="swSidebarMode"
                 id="swSidebarMode"
@@ -74,7 +71,7 @@ export const UISettings = (): JSX.Element => {
               <label className="form-label form-check-label" htmlFor="swSidebarMode"></label>
               <label className="form-label form-check-label" htmlFor="swSidebarMode"></label>
             </div>
             </div>
             <IconWithTooltip id="iwt-sidebar-dock" label="Dock" additionalClasses={styles['grw-sidebar-mode-icon']}>
             <IconWithTooltip id="iwt-sidebar-dock" label="Dock" additionalClasses={styles['grw-sidebar-mode-icon']}>
-              <SidebarDockIcon />
+              <span className="growi-custom-icons">sidebar-dock</span>
             </IconWithTooltip>
             </IconWithTooltip>
           </div>
           </div>
           <div className="ms-2">
           <div className="ms-2">

+ 2 - 0
apps/app/src/server/service/mail.ts

@@ -199,6 +199,8 @@ class MailService implements S2sMessageHandlable {
     const templateVars = config.vars || {};
     const templateVars = config.vars || {};
     const output = await renderFilePromisified(
     const output = await renderFilePromisified(
       config.template,
       config.template,
+      // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+      // @ts-ignore
       templateVars,
       templateVars,
     );
     );
 
 

+ 8 - 0
apps/app/src/styles/_fonts.scss

@@ -21,3 +21,11 @@
     font-variation-settings: 'FILL' 1;
     font-variation-settings: 'FILL' 1;
   }
   }
 }
 }
+
+.growi-custom-icons {
+  font-family: var(--grw-font-family-custom-icon);
+  font-size: 16px;
+  font-style: normal;
+  -webkit-font-smoothing: auto;
+  -moz-osx-font-smoothing: auto;
+}

+ 1 - 0
packages/custom-icons/.gitignore

@@ -0,0 +1 @@
+/dist

+ 7 - 0
packages/custom-icons/.svgtofontrc

@@ -0,0 +1,7 @@
+{
+  "fontName": "growi-custom-icons",
+  "css": false,
+  "outSVGReact": false,
+  "useNameAsUnicode": true,
+  "className": "growi-custom-icons"
+}

+ 12 - 0
packages/custom-icons/package.json

@@ -0,0 +1,12 @@
+{
+  "name": "@growi/custom-icons",
+  "version": "7.0.0-RC.0",
+  "license": "MIT",
+  "scripts": {
+    "build": "svgtofont --sources ./svg --output ./dist",
+    "dev": "svgtofont --sources ./svg --output ./dist"
+  },
+  "devDependencies": {
+    "svgtofont": "^4.1.1"
+  }
+}

+ 19 - 0
packages/custom-icons/svg/sidebar-collapsed.svg

@@ -0,0 +1,19 @@
+<svg
+  xmlns="http://www.w3.org/2000/svg"
+  viewBox="0 0 23 23"
+>
+  <rect width="23" height="23" fill="none" />
+  <path d="M20.9,3.9c0.3,0,0.6,0.3,0.6,0.6v13.9c0,0.3-0.3,0.6-0.6,0.6H2.1c-0.3,0-0.6-0.3-0.6-0.6V4.5c0-0.3,0.3-0.6,0.6-0.6H20.9
+    M20.9,2.4H2.1C1,2.4,0,3.4,0,4.5c0,0,0,0,0,0v13.9c0,1.2,1,2.1,2.1,2.1c0,0,0,0,0,0h18.7c1.2,0,2.1-0.9,2.1-2.1c0,0,0,0,0,0V4.5
+    C23,3.4,22,2.4,20.9,2.4C20.9,2.4,20.9,2.4,20.9,2.4z"
+  />
+  <rect x="7.5" y="3.9" width="1.2" height="0.8" />
+  <rect x="7.5" y="15.3" width="1.2" height="1.5" />
+  <rect x="7.5" y="12.3" width="1.2" height="1.5" />
+  <rect x="7.5" y="9.2" width="1.2" height="1.6" />
+  <rect x="7.5" y="6.1" width="1.2" height="1.6" />
+  <rect x="7.5" y="18.4" width="1.2" height="0.8" />
+  <path d="M15.1,14.9c-0.2,0-0.3-0.1-0.4-0.2l-2.8-2.8c-0.2-0.2-0.2-0.6,0-0.8l2.8-2.8c0.2-0.2,0.6-0.2,0.9,0s0.2,0.6,0,0.9l-2.4,2.4
+    l2.4,2.4c0.2,0.2,0.2,0.6,0,0.9C15.4,14.8,15.3,14.9,15.1,14.9z"
+  />
+</svg>

+ 12 - 0
packages/custom-icons/svg/sidebar-dock.svg

@@ -0,0 +1,12 @@
+<svg
+  xmlns="http://www.w3.org/2000/svg"
+  viewBox="0 0 23 23"
+>
+  <rect width="23" height="23" fill="none" />
+  <path
+    d="M20.86,3.92a.64.64,0,0,1,.64.63v13.9a.64.64,0,0,1-.64.63H2.14a.64.64,0,0,
+    1-.64-.63V4.55a.64.64,0,0,1,.64-.63H20.86m0-1.5H2.14A2.13,2.13,0,0,0,0,4.55v13.9a2.13,
+    2.13,0,0,0,2.14,2.13H20.86A2.13,2.13,0,0,0,23,18.45V4.55a2.13,2.13,0,0,0-2.14-2.13Z"
+  />
+  <rect x="7.49" y="3.05" width="1.2" height="16.91" />
+</svg>

+ 16 - 0
packages/custom-icons/turbo.json

@@ -0,0 +1,16 @@
+{
+  "$schema": "https://turbo.build/schema.json",
+  "extends": ["//"],
+  "pipeline": {
+    "build": {
+      "outputs": ["dist/**"],
+      "inputs": ["svg/**"],
+      "outputMode": "new-only"
+    },
+    "dev": {
+      "outputs": ["dist/**"],
+      "inputs": ["svg/**"],
+      "outputMode": "new-only"
+    }
+  }
+}

Разлика између датотеке није приказан због своје велике величине
+ 570 - 6
yarn.lock


Неке датотеке нису приказане због велике количине промена