Skip to content

Commit

Permalink
Merge pull request #15 from HiDeoo/hd-zero-size-svgs
Browse files Browse the repository at this point in the history
  • Loading branch information
HiDeoo committed Jul 16, 2024
2 parents 3b629e6 + 8b762e6 commit a035c21
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/src/content/docs/tests/shared-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ An image using Markdown syntax with no alt text:

![](../../../assets/tests/starlight-light.png)

A remote SVG image with no explicit width using Markdown syntax:

![D2 diagram](https://d2.atlas.lucas.tools/?script=KkktLuECBAAA__8%3D&)

An image using HTML syntax with the `img` tag:

<img src="https://astro.build/assets/press/astro-logo-light-gradient.png" alt="Astro logo" />
Expand Down
4 changes: 4 additions & 0 deletions docs/src/content/docs/tests/shared-syntax.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ An image using Markdown syntax with no alt text:

![](../../../assets/tests/starlight-light.png)

A remote SVG image with no explicit width using Markdown syntax:

![D2 diagram](https://d2.atlas.lucas.tools/?script=KkktLuECBAAA__8%3D&)

An image using HTML syntax with the `img` tag:

<img src="https://astro.build/assets/press/astro-logo-light-gradient.png" alt="Astro logo" />
Expand Down
8 changes: 7 additions & 1 deletion packages/starlight-image-zoom/components/ImageZoom.astro
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import config from 'virtual:starlight-image-zoom-config'
starlight-image-zoom-zoomable {
display: inline-block;
position: relative;
width: 100%;
}

starlight-image-zoom-zoomable img {
Expand Down Expand Up @@ -64,13 +65,18 @@ import config from 'virtual:starlight-image-zoom-config'
border-radius: 50%;
display: grid;
height: 44px;
inset: 20px 20px auto auto;
inset: 20px auto auto 20px;
margin-top: 0 !important;
padding: 10px;
place-items: center;
position: absolute;
width: 44px;
}

.starlight-image-zoom-opened .starlight-image-zoom-control {
inset: 20px 20px auto auto;
}

.starlight-image-zoom-source {
visibility: hidden;
}
Expand Down
11 changes: 10 additions & 1 deletion packages/starlight-image-zoom/tests/shared-syntax.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ for (const format of formats) {
await testPage.page.emulateMedia({ colorScheme: 'light' })
await testPage.goto(slug)

const image = testPage.getNthImage(4)
const image = testPage.getNthImage(5)
await testPage.zoomImage(image)

expect(await testPage.getZoomedImage().getAttribute('src')).toMatch(/-dark.png$/)
Expand All @@ -55,4 +55,13 @@ for (const format of formats) {

expect(await testPage.getZoomedImage().getAttribute('src')).toMatch(/-light.png$/)
})

test(`${format}: displays remote SVGs with no explicit width`, async ({ testPage }) => {
await testPage.goto(slug)

const image = testPage.getNthImage(3)
const boundingBox = await image.boundingBox()

expect(boundingBox?.width).not.toBe(0)
})
}

0 comments on commit a035c21

Please sign in to comment.