mirror of
https://github.com/gromlab-ru/svg-sprites.git
synced 2026-07-22 04:40:17 +03:00
feat: добавить серверную генерацию спрайтов
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
<script setup>
|
||||
import '@gromlab/svg-sprites/viewer/element'
|
||||
|
||||
import { IconsIcon } from './sprite'
|
||||
import { AppIcon } from './app-icons/index.js'
|
||||
import { RemoteAppIcon } from './remote-app-icons/index.js'
|
||||
|
||||
const viewerSources = [
|
||||
() => import('./sprite/.svg-sprite/svg-sprite.manifest.js'),
|
||||
() => import('./app-icons/.svg-sprite/svg-sprite.manifest.js'),
|
||||
() => import('./remote-app-icons/.svg-sprite/svg-sprite.manifest.js'),
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
<h1>Vue + Vite</h1>
|
||||
<IconsIcon
|
||||
<AppIcon
|
||||
data-testid="icon"
|
||||
data-app="vue-vite"
|
||||
icon="check"
|
||||
@@ -20,6 +22,15 @@ const viewerSources = [
|
||||
height="64"
|
||||
style="--icon-color-1: #16a34a"
|
||||
/>
|
||||
<RemoteAppIcon
|
||||
data-testid="remote-icon"
|
||||
data-app="vue-vite-remote"
|
||||
icon="check"
|
||||
aria-label="Remote check icon"
|
||||
width="64"
|
||||
height="64"
|
||||
style="--icon-color-1: #16a34a"
|
||||
/>
|
||||
<gromlab-sprite-viewer
|
||||
:sources="viewerSources"
|
||||
viewer-title="Vue Vite Viewer"
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineSpriteConfig } from '@gromlab/svg-sprites'
|
||||
|
||||
export default defineSpriteConfig({
|
||||
mode: 'vue@vite',
|
||||
name: 'icons',
|
||||
name: 'app',
|
||||
input: '../../../../fixtures/icons/check.svg',
|
||||
generatedNotice: false,
|
||||
})
|
||||
@@ -1,9 +1,26 @@
|
||||
import type { IconsIconName, IconsIconProps } from './sprite/.svg-sprite/index.js'
|
||||
import { AppIcon } from './app-icons/.svg-sprite/index.js'
|
||||
import type { AppIconName, AppIconProps } from './app-icons/.svg-sprite/index.js'
|
||||
import { RemoteAppIcon } from './remote-app-icons/.svg-sprite/index.js'
|
||||
import type {
|
||||
RemoteAppIconName,
|
||||
RemoteAppIconProps,
|
||||
} from './remote-app-icons/.svg-sprite/index.js'
|
||||
|
||||
const icon: IconsIconName = 'check'
|
||||
const props: IconsIconProps = { icon, width: 24, height: 24 }
|
||||
void props
|
||||
const iconName: AppIconName = 'check'
|
||||
const iconProps: AppIconProps = { icon: iconName, width: 24, height: 24 }
|
||||
const remoteIconName: RemoteAppIconName = 'check'
|
||||
const remoteIconProps: RemoteAppIconProps = {
|
||||
icon: remoteIconName,
|
||||
width: 24,
|
||||
height: 24,
|
||||
}
|
||||
|
||||
void [AppIcon, RemoteAppIcon, iconProps, remoteIconProps]
|
||||
|
||||
// @ts-expect-error generated icon names are a closed union
|
||||
const invalidIcon: IconsIconName = 'missing'
|
||||
const invalidIcon: AppIconName = 'missing'
|
||||
void invalidIcon
|
||||
|
||||
// @ts-expect-error generated remote icon names are a closed union
|
||||
const invalidRemoteIcon: RemoteAppIconName = 'missing'
|
||||
void invalidRemoteIcon
|
||||
|
||||
2
integration/apps/vue-vite/src/remote-app-icons/.gitignore
vendored
Normal file
2
integration/apps/vue-vite/src/remote-app-icons/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# @generated by @gromlab/svg-sprites. Do not edit.
|
||||
/.svg-sprite/
|
||||
1
integration/apps/vue-vite/src/remote-app-icons/index.d.ts
vendored
Normal file
1
integration/apps/vue-vite/src/remote-app-icons/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './.svg-sprite/index.js'
|
||||
1
integration/apps/vue-vite/src/remote-app-icons/index.js
Normal file
1
integration/apps/vue-vite/src/remote-app-icons/index.js
Normal file
@@ -0,0 +1 @@
|
||||
export * from './.svg-sprite'
|
||||
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
mode: 'vue@vite',
|
||||
source: 'remote',
|
||||
input: process.env.SVG_SPRITE_REMOTE_MANIFEST_URL
|
||||
?? '../../../standalone-server/cases/mixed-input/.svg-sprite/svg-sprite.manifest.json',
|
||||
}
|
||||
Reference in New Issue
Block a user