From 80a6f2ce7cd960576477cf63ebc6f6f09ca06021 Mon Sep 17 00:00:00 2001
From: Dylan Staley <88163+dstaley@users.noreply.github.com>
Date: Wed, 10 Jan 2024 12:13:37 -0800
Subject: [PATCH] feat: use actual inline SVGs instead of svg?include imports
---
.changeset/cool-mirrors-live.md | 5 +++
package-lock.json | 14 ++++----
packages/button/icons/arrow-right.svg | 1 -
packages/button/icons/arrow-right.tsx | 21 ++++++++++++
packages/button/icons/corner-right-down.svg | 1 -
packages/button/icons/corner-right-down.tsx | 27 +++++++++++++++
packages/button/icons/download.svg | 1 -
packages/button/icons/download.tsx | 29 ++++++++++++++++
packages/button/icons/external-link.svg | 1 -
packages/button/icons/external-link.tsx | 30 ++++++++++++++++
packages/button/index.tsx | 38 +++++++++++++++------
packages/button/types.ts | 3 +-
12 files changed, 148 insertions(+), 23 deletions(-)
create mode 100644 .changeset/cool-mirrors-live.md
delete mode 100644 packages/button/icons/arrow-right.svg
create mode 100644 packages/button/icons/arrow-right.tsx
delete mode 100644 packages/button/icons/corner-right-down.svg
create mode 100644 packages/button/icons/corner-right-down.tsx
delete mode 100644 packages/button/icons/download.svg
create mode 100644 packages/button/icons/download.tsx
delete mode 100644 packages/button/icons/external-link.svg
create mode 100644 packages/button/icons/external-link.tsx
diff --git a/.changeset/cool-mirrors-live.md b/.changeset/cool-mirrors-live.md
new file mode 100644
index 000000000..269c0e761
--- /dev/null
+++ b/.changeset/cool-mirrors-live.md
@@ -0,0 +1,5 @@
+---
+'@hashicorp/react-button': patch
+---
+
+Use inline SVGs to replace svg?include imports
diff --git a/package-lock.json b/package-lock.json
index 8c4dffd8b..bb82797bb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -39545,7 +39545,7 @@
},
"packages/accordion": {
"name": "@hashicorp/react-accordion",
- "version": "3.0.2",
+ "version": "3.1.0",
"license": "MPL-2.0",
"dependencies": {
"classnames": "^2.3.1"
@@ -39585,7 +39585,7 @@
},
"packages/alert-banner": {
"name": "@hashicorp/react-alert-banner",
- "version": "7.1.0",
+ "version": "7.2.0",
"license": "MPL-2.0",
"dependencies": {
"@hashicorp/platform-product-meta": "^0.1.0",
@@ -39744,7 +39744,7 @@
},
"packages/code-block": {
"name": "@hashicorp/react-code-block",
- "version": "6.4.0",
+ "version": "6.6.0",
"license": "MPL-2.0",
"dependencies": {
"shellwords": "^0.1.1"
@@ -39934,7 +39934,7 @@
},
"packages/docs-page": {
"name": "@hashicorp/react-docs-page",
- "version": "17.9.0",
+ "version": "17.9.1",
"license": "MPL-2.0",
"dependencies": {
"@hashicorp/platform-docs-mdx": "^0.2.0",
@@ -40452,7 +40452,7 @@
},
"packages/logo-grid": {
"name": "@hashicorp/react-logo-grid",
- "version": "5.1.0",
+ "version": "5.2.0",
"license": "MPL-2.0",
"dependencies": {
"@hashicorp/react-button": "^6.3.1",
@@ -40984,7 +40984,7 @@
},
"packages/split-rich-cta-list": {
"name": "@hashicorp/react-split-rich-cta-list",
- "version": "2.0.4",
+ "version": "2.1.0",
"license": "MPL-2.0",
"dependencies": {
"@hashicorp/platform-product-meta": "^0.1.0",
@@ -41058,7 +41058,7 @@
},
"packages/tabs": {
"name": "@hashicorp/react-tabs",
- "version": "8.0.0",
+ "version": "8.1.0",
"license": "MPL-2.0",
"dependencies": {
"classnames": "^2.3.1"
diff --git a/packages/button/icons/arrow-right.svg b/packages/button/icons/arrow-right.svg
deleted file mode 100644
index 9fd931173..000000000
--- a/packages/button/icons/arrow-right.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/packages/button/icons/arrow-right.tsx b/packages/button/icons/arrow-right.tsx
new file mode 100644
index 000000000..739df9919
--- /dev/null
+++ b/packages/button/icons/arrow-right.tsx
@@ -0,0 +1,21 @@
+import * as React from 'react'
+import { SVGProps } from 'react'
+const SvgComponent = (props: SVGProps) => (
+
+)
+export default SvgComponent
diff --git a/packages/button/icons/corner-right-down.svg b/packages/button/icons/corner-right-down.svg
deleted file mode 100644
index afcee5881..000000000
--- a/packages/button/icons/corner-right-down.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/packages/button/icons/corner-right-down.tsx b/packages/button/icons/corner-right-down.tsx
new file mode 100644
index 000000000..1b326cef7
--- /dev/null
+++ b/packages/button/icons/corner-right-down.tsx
@@ -0,0 +1,27 @@
+import * as React from 'react'
+import { SVGProps } from 'react'
+const SvgComponent = (props: SVGProps) => (
+
+)
+export default SvgComponent
diff --git a/packages/button/icons/download.svg b/packages/button/icons/download.svg
deleted file mode 100644
index 1ec556705..000000000
--- a/packages/button/icons/download.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/packages/button/icons/download.tsx b/packages/button/icons/download.tsx
new file mode 100644
index 000000000..bea633e2f
--- /dev/null
+++ b/packages/button/icons/download.tsx
@@ -0,0 +1,29 @@
+import * as React from 'react'
+import { SVGProps } from 'react'
+const SvgComponent = (props: SVGProps) => (
+
+)
+export default SvgComponent
diff --git a/packages/button/icons/external-link.svg b/packages/button/icons/external-link.svg
deleted file mode 100644
index 5ac13045d..000000000
--- a/packages/button/icons/external-link.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/packages/button/icons/external-link.tsx b/packages/button/icons/external-link.tsx
new file mode 100644
index 000000000..d7df07ca7
--- /dev/null
+++ b/packages/button/icons/external-link.tsx
@@ -0,0 +1,30 @@
+import * as React from 'react'
+import { SVGProps } from 'react'
+const SvgComponent = (props: SVGProps) => (
+
+)
+export default SvgComponent
diff --git a/packages/button/index.tsx b/packages/button/index.tsx
index 993d1aa7c..d28d060ca 100644
--- a/packages/button/index.tsx
+++ b/packages/button/index.tsx
@@ -10,10 +10,10 @@ import fragment from './fragment.graphql'
import classNames from 'classnames'
import useProductMeta from '@hashicorp/platform-product-meta'
import InlineSvg from '@hashicorp/react-inline-svg'
-import svgArrowRight from './icons/arrow-right.svg?include'
-import svgExternalLink from './icons/external-link.svg?include'
-import svgCornerRightDown from './icons/corner-right-down.svg?include'
-import svgDownload from './icons/download.svg?include'
+import ArrowRight from './icons/arrow-right'
+import ExternalLink from './icons/external-link'
+import CornerRightDown from './icons/corner-right-down'
+import Download from './icons/download'
import s from './style.module.css'
import sTheme from './theme.module.css'
import useHover from './hooks/use-hover'
@@ -21,10 +21,10 @@ import normalizeButtonTheme from './helpers/normalizeButtonTheme.js'
import { Size, LinkType, IconObject, Theme, IconProps } from './types'
const linkTypeToIcon = {
- inbound: svgArrowRight,
- outbound: svgExternalLink,
- anchor: svgCornerRightDown,
- download: svgDownload,
+ inbound: ,
+ outbound: ,
+ anchor: ,
+ download: ,
}
interface ButtonProps {
@@ -137,8 +137,23 @@ function Icon({
isHovered,
size,
}: IconProps) {
+ if (typeof svg === 'string') {
+ return (
+
+ )
+ }
+
return (
-
+ >
+ {svg}
+
)
}
diff --git a/packages/button/types.ts b/packages/button/types.ts
index f0a2753fa..94625c096 100644
--- a/packages/button/types.ts
+++ b/packages/button/types.ts
@@ -3,6 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/
+import type { ReactNode } from 'react'
import { Products as HashiCorpProduct } from '@hashicorp/platform-product-meta'
export type Size = 'medium' | 'small'
@@ -39,7 +40,7 @@ export interface Theme {
}
export interface IconProps {
- svg: string
+ svg: ReactNode
position: IconPosition
animationId?: LinkType
isAnimated?: boolean