diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index b7f869c3..c2de8e90 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -35,7 +35,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a0fa3029..f8db0d39 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -16,7 +16,7 @@ jobs: name: build-lint-test - node ${{ matrix.node_version }} steps: - name: Check out Git repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v3 @@ -24,7 +24,7 @@ jobs: node-version: ${{ matrix.node_version }} - name: Get yarn cache - uses: actions/cache@v2 + uses: actions/cache@v4 id: yarn-cache with: path: | @@ -58,7 +58,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out Git repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v3 @@ -66,7 +66,7 @@ jobs: node-version: 20 - name: Get yarn cache - uses: actions/cache@v2 + uses: actions/cache@v4 id: yarn-cache with: path: | @@ -87,8 +87,7 @@ jobs: if: github.event.pull_request.head.repo.full_name == github.repository steps: - name: Check out Git repository - uses: - actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v3 @@ -96,7 +95,7 @@ jobs: node-version: 20 - name: Get yarn cache - uses: actions/cache@v2 + uses: actions/cache@v4 id: yarn-cache with: path: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f923e7b..a547c677 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out Git repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 # Use custom token from repo secrets to allow semantic release to push commit: @@ -24,7 +24,7 @@ jobs: node-version: 20 - name: Get yarn cache - uses: actions/cache@v3 + uses: actions/cache@v4 id: yarn-cache with: path: | diff --git a/.github/workflows/visual.yml b/.github/workflows/visual.yml index 809d54d0..78dfc1a3 100644 --- a/.github/workflows/visual.yml +++ b/.github/workflows/visual.yml @@ -13,7 +13,7 @@ jobs: if: ${{ !github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository }} steps: - name: Check out Git repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v3 @@ -21,7 +21,7 @@ jobs: node-version: 20 - name: Get yarn cache - uses: actions/cache@v2 + uses: actions/cache@v4 id: yarn-cache with: path: | diff --git a/packages/embed/src/css/popover.scss b/packages/embed/src/css/popover.scss index 777b5c84..d7206bf2 100644 --- a/packages/embed/src/css/popover.scss +++ b/packages/embed/src/css/popover.scss @@ -120,20 +120,26 @@ } &-close { - color: rgba(0, 0, 0, 0.2); cursor: pointer; margin-left: 4px; display: inline-block; - width: 20px; - height: 20px; - font-size: 18px; text-align: center; position: absolute; - top: 8px; + top: 12px; right: 6px; - &:hover { - color: rgba(0, 0, 0, 0.3); + svg { + width: 20px; + height: 20px; + } + + svg path { + fill: rgba(0, 0, 0, 0.2); + transition: fill 150ms ease-in-out; + } + + &:hover svg path { + fill: rgba(0, 0, 0, 0.3); } } diff --git a/packages/embed/src/factories/create-popover/create-popover.ts b/packages/embed/src/factories/create-popover/create-popover.ts index c23cd625..7b0a2b8d 100644 --- a/packages/embed/src/factories/create-popover/create-popover.ts +++ b/packages/embed/src/factories/create-popover/create-popover.ts @@ -11,6 +11,8 @@ import { invokeWithoutDefault, addAttributesToElement, handlePreventReopenOnClose, + closeIconSvg, + triggerIconSvg, } from '../../utils' import type { RemoveHandler } from '../../utils' import { ButtonProps, EmbedPopup } from '../../base' @@ -38,7 +40,7 @@ const buildPopover = (width?: number | string, height?: number | string) => { const buildCloseIcon = (element = 'span', className = 'tf-v1-popover-button-icon') => { const icon = document.createElement(element) icon.className = `${className} tf-v1-close-icon` - icon.innerHTML = '×' + icon.innerHTML = closeIconSvg icon.dataset.testid = className return icon } @@ -65,13 +67,7 @@ const buildIcon = (customIcon?: string, color?: string) => { const triggerIcon = document.createElement('div') triggerIcon.className = 'tf-v1-popover-button-icon' - const svgIcon = ` - - ` + const svgIcon = triggerIconSvg(fillColor) const isUrlIcon = customIcon?.startsWith('http') triggerIcon.innerHTML = isUrlIcon @@ -97,7 +93,7 @@ const buildTooltip = (message: string, hide: () => void) => { const icon = document.createElement('span') icon.className = 'tf-v1-popover-tooltip-close' icon.dataset.testid = 'tf-v1-popover-tooltip-close' - icon.innerHTML = '×' + icon.innerHTML = closeIconSvg icon.onclick = hide const textContainer = document.createElement('div') diff --git a/packages/embed/src/factories/create-popup/create-popup.ts b/packages/embed/src/factories/create-popup/create-popup.ts index ef027e7a..17b5b90e 100644 --- a/packages/embed/src/factories/create-popup/create-popup.ts +++ b/packages/embed/src/factories/create-popup/create-popup.ts @@ -9,6 +9,7 @@ import { addCustomKeyboardListener, invokeWithoutDefault, handlePreventReopenOnClose, + closeIconSvg, } from '../../utils' import type { RemoveHandler } from '../../utils' import { POPUP_SIZE } from '../../constants' @@ -51,7 +52,7 @@ const buildWrapper = (width?: number | string, height?: number | string, size?: const buildCloseButton = (close: () => void) => { const closeButton = document.createElement('button') closeButton.className = 'tf-v1-close tf-v1-close-icon' - closeButton.innerHTML = '×' + closeButton.innerHTML = closeIconSvg closeButton.ariaLabel = 'Close' closeButton.onclick = invokeWithoutDefault(close) return closeButton diff --git a/packages/embed/src/factories/create-sidetab/create-sidetab.ts b/packages/embed/src/factories/create-sidetab/create-sidetab.ts index 2fe084c9..a382d552 100644 --- a/packages/embed/src/factories/create-sidetab/create-sidetab.ts +++ b/packages/embed/src/factories/create-sidetab/create-sidetab.ts @@ -12,6 +12,8 @@ import { addAttributesToElement, getValueWithUnits, handlePreventReopenOnClose, + closeIconSvg, + triggerIconSvg, } from '../../utils' import type { RemoveHandler } from '../../utils' import { ButtonProps, EmbedPopup } from '../../base' @@ -125,9 +127,7 @@ const buildIcon = (customIcon?: string, backgroundColor?: string, textColor?: st triggerIcon.style.height = getValueWithUnits(size) } - const svgIcon = ` - - ` + const svgIcon = triggerIconSvg(fillColor) const isUrlIcon = customIcon?.startsWith('http') triggerIcon.innerHTML = isUrlIcon @@ -141,7 +141,7 @@ const buildIcon = (customIcon?: string, backgroundColor?: string, textColor?: st const buildCloseIcon = (element = 'div', className = 'tf-v1-sidetab-button-icon') => { const closeButton = document.createElement(element) closeButton.className = `${className} tf-v1-close-icon` - closeButton.innerHTML = '×' + closeButton.innerHTML = closeIconSvg closeButton.dataset.testid = className return closeButton } diff --git a/packages/embed/src/factories/create-slider/create-slider.ts b/packages/embed/src/factories/create-slider/create-slider.ts index 29b898ce..6fac6e72 100644 --- a/packages/embed/src/factories/create-slider/create-slider.ts +++ b/packages/embed/src/factories/create-slider/create-slider.ts @@ -10,6 +10,7 @@ import { isInPage, invokeWithoutDefault, handlePreventReopenOnClose, + closeIconSvg, } from '../../utils' import type { RemoveHandler } from '../../utils' import { SLIDER_POSITION, SLIDER_WIDTH } from '../../constants' @@ -45,7 +46,7 @@ const buildWrapper = (position: Position, width: number | string) => { const buildCloseButton = (close: () => void) => { const closeButton = document.createElement('button') closeButton.className = 'tf-v1-close tf-v1-close-icon' - closeButton.innerHTML = '×' + closeButton.innerHTML = closeIconSvg closeButton.ariaLabel = 'Close' closeButton.onclick = invokeWithoutDefault(close) return closeButton diff --git a/packages/embed/src/utils/close-icon-svg.ts b/packages/embed/src/utils/close-icon-svg.ts new file mode 100644 index 00000000..e8b81701 --- /dev/null +++ b/packages/embed/src/utils/close-icon-svg.ts @@ -0,0 +1,3 @@ +export const closeIconSvg = ` + +` diff --git a/packages/embed/src/utils/index.ts b/packages/embed/src/utils/index.ts index 88ef3ed6..67707b66 100644 --- a/packages/embed/src/utils/index.ts +++ b/packages/embed/src/utils/index.ts @@ -18,3 +18,5 @@ export * from './change-color-opacity' export * from './hubspot' export * from './invoke-without-default' export * from './add-attributes-to-element' +export * from './close-icon-svg' +export * from './trigger-icon-svg' diff --git a/packages/embed/src/utils/trigger-icon-svg.ts b/packages/embed/src/utils/trigger-icon-svg.ts new file mode 100644 index 00000000..9c42d054 --- /dev/null +++ b/packages/embed/src/utils/trigger-icon-svg.ts @@ -0,0 +1,16 @@ +export const triggerIconSvg = ( + fillColor: string +) => ` + + + `