diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..f16c8790 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Publish to npm + +on: + push: + tags: + - '[0-9]*.[0-9]*.[0-9]*' + +permissions: + id-token: write + contents: read + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # npm trusted publishing (OIDC) requires npm CLI >= 11.5.1, which ships with Node 24 + - uses: actions/setup-node@v4 + with: + node-version: 24 + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + + - name: Publish to NPM + run: | + if [[ "${{ github.ref_name }}" == *"-beta"* ]]; then + npm publish --access public --tag beta + else + npm publish --access public + fi diff --git a/__tests__/charts/utils/createSvg.spec.ts b/__tests__/charts/utils/createSvg.spec.ts index 9fb9d144..5ae1e07a 100644 --- a/__tests__/charts/utils/createSvg.spec.ts +++ b/__tests__/charts/utils/createSvg.spec.ts @@ -42,7 +42,13 @@ describe('createSvg', () => { const svg = selection.node() as HTMLElement; expect(svg.style.margin).toBe('0px 4px'); - expect(svg.style.transform).toBe('translate(0px, 0.125em)'); + }); + + it('should make the container a centering inline-flex box', () => { + createSvg(testContainer, 100, 200); + + expect(testContainer.style.display).toBe('inline-flex'); + expect(testContainer.style.alignItems).toBe('center'); }); it('should create SVG in proper namespace', () => { @@ -129,6 +135,6 @@ describe('createSvg', () => { const svg2 = selection2.node() as HTMLElement; expect(svg1.style.margin).toBe(svg2.style.margin); - expect(svg1.style.transform).toBe(svg2.style.transform); + expect(svg1.style.display).toBe(svg2.style.display); }); }); diff --git a/__tests__/snapshot/text-register-plugin.html b/__tests__/snapshot/text-register-plugin.html index 686a0547..50607d7e 100644 --- a/__tests__/snapshot/text-register-plugin.html +++ b/__tests__/snapshot/text-register-plugin.html @@ -166,7 +166,7 @@ margin: 0px 2px; " class="t8-value t8-delta_value t8-value-positive" - >+$180.3k+$180.3k relative to the same time last quarter. They are up +$106.1k+$106.1k relative to the same time last year. They are +$50.6k+$50.6k) @@ -321,7 +321,7 @@ margin: 0px 2px; " class="t8-value t8-delta_value t8-value-positive" - >+$86.2k+$86.2k) @@ -359,7 +359,7 @@ margin: 0px 2px; " class="t8-value t8-delta_value t8-value-positive" - >+$160.1k+$160.1k) @@ -426,7 +426,7 @@ margin: 0px 2px; " class="t8-value t8-delta_value t8-value-positive" - >+17+17 relative to the same time last quarter (-$2k-$2k relative to the same time last quarter (+$180.3k+$180.3k relative to the same time last quarter. They are up +$106.1k+$106.1k relative to the same time last year. They are +$50.6k+$50.6k) @@ -319,7 +319,7 @@ margin: 0px 2px; " class="t8-value t8-delta_value t8-value-positive" - >+$86.2k+$86.2k) @@ -356,7 +356,7 @@ margin: 0px 2px; " class="t8-value t8-delta_value t8-value-positive" - >+$160.1k+$160.1k) @@ -423,7 +423,7 @@ margin: 0px 2px; " class="t8-value t8-delta_value t8-value-positive" - >+17+17 relative to the same time last quarter (-$2k-$2k relative to the same time last quarter ( { const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); svg.style.margin = '0px 4px'; - svg.style.transform = 'translate(0px, 0.125em)'; - svg.style.display = 'inline-block'; + + // The container is a wrapper span between the outer inline-flex phrase span and this svg. + // Make it a centering flex box as well, so the svg is centered against the text instead of + // sitting on the baseline of its own line box. + if (container instanceof HTMLElement) { + container.style.display = 'inline-flex'; + container.style.alignItems = 'center'; + } svg.setAttribute('height', String(height)); svg.setAttribute('width', String(width)); diff --git a/src/plugin/utils/createInlineDocument.ts b/src/plugin/utils/createInlineDocument.ts index 6d5b47f5..f270bd29 100644 --- a/src/plugin/utils/createInlineDocument.ts +++ b/src/plugin/utils/createInlineDocument.ts @@ -12,6 +12,8 @@ export const createInlineDocument = ( position: 'suffix' | 'prefix' = 'suffix', ): HTMLSpanElement => { const span = document.createElement('span'); + span.style.display = 'inline-flex'; + span.style.alignItems = 'center'; const originalElementSpan = value; span.textContent = originalElementSpan;