Skip to content

Commit

Permalink
Fix SVG export compatibility by removing rgba strings (#3825)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jul 20, 2023
1 parent 612df29 commit 130aa25
Show file tree
Hide file tree
Showing 21 changed files with 297 additions and 319 deletions.
1 change: 1 addition & 0 deletions plugins/breakpoint-split-view/package.json
Expand Up @@ -39,6 +39,7 @@
"@gmod/vcf": "^5.0.9",
"@mui/icons-material": "^5.0.1",
"@types/file-saver": "^2.0.1",
"color": "^3.1.3",
"file-saver": "^2.0.0"
},
"peerDependencies": {
Expand Down
@@ -1,5 +1,6 @@
import React from 'react'
import { useTheme } from '@mui/material'
import Color from 'color'

export default function SVGBackground({
width,
Expand All @@ -15,7 +16,7 @@ export default function SVGBackground({
<rect
width={width + shift * 2}
height={height}
fill={theme.palette.background.default}
fill={Color(theme.palette.background.default).hex()}
/>
)
}
1 change: 1 addition & 0 deletions plugins/circular-view/package.json
Expand Up @@ -39,6 +39,7 @@
"@mui/icons-material": "^5.0.1",
"@types/file-saver": "^2.0.0",
"clone": "^2.1.2",
"color": "^3.1.3",
"file-saver": "^2.0.0"
},
"peerDependencies": {
Expand Down
@@ -1,5 +1,6 @@
import React from 'react'
import { useTheme } from '@mui/material'
import Color from 'color'

export default function SVGBackground({
width,
Expand All @@ -15,7 +16,7 @@ export default function SVGBackground({
<rect
width={width + shift * 2}
height={height}
fill={theme.palette.background.default}
fill={Color(theme.palette.background.default).hex()}
/>
)
}
1 change: 1 addition & 0 deletions plugins/dotplot-view/package.json
Expand Up @@ -42,6 +42,7 @@
"@types/file-saver": "^2.0.1",
"@types/normalize-wheel": "^1.0.0",
"clone": "^2.1.2",
"color": "^3.1.3",
"file-saver": "^2.0.0",
"normalize-wheel": "^1.0.1",
"react-popper": "^2.0.0"
Expand Down
@@ -1,4 +1,5 @@
import React from 'react'
import Color from 'color'
import { useTheme } from '@mui/material'

export default function SVGBackground({
Expand All @@ -15,7 +16,7 @@ export default function SVGBackground({
y={0}
width={width}
height={height}
fill={theme.palette.background.default}
fill={Color(theme.palette.background.default).hex()}
/>
)
}
1 change: 1 addition & 0 deletions plugins/linear-comparative-view/package.json
Expand Up @@ -39,6 +39,7 @@
"@mui/icons-material": "^5.0.1",
"@popperjs/core": "^2.0.0",
"clone": "^2.1.2",
"color": "^3.1.3",
"copy-to-clipboard": "^3.3.1",
"file-saver": "^2.0.0",
"react-popper": "^2.0.0"
Expand Down
@@ -1,5 +1,6 @@
import React from 'react'
import { useTheme } from '@mui/material'
import Color from 'color'

export default function SVGBackground({
width,
Expand All @@ -15,7 +16,7 @@ export default function SVGBackground({
<rect
width={width + shift * 2}
height={height}
fill={theme.palette.background.default}
fill={Color(theme.palette.background.default).hex()}
/>
)
}
1 change: 1 addition & 0 deletions plugins/linear-genome-view/package.json
Expand Up @@ -44,6 +44,7 @@
"@types/normalize-wheel": "^1.0.0",
"clone": "^2.1.2",
"clsx": "^1.0.4",
"color": "^3.1.3",
"copy-to-clipboard": "^3.3.1",
"file-saver": "^2.0.0",
"material-ui-popup-state": "^5.0.0",
Expand Down
@@ -1,5 +1,6 @@
import React from 'react'
import { useTheme } from '@mui/material'
import Color from 'color'

export default function SVGBackground({
width,
Expand All @@ -15,7 +16,7 @@ export default function SVGBackground({
<rect
width={width + shift * 2}
height={height}
fill={theme.palette.background.default}
fill={Color(theme.palette.background.default).hex()}
/>
)
}
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { getSession } from '@jbrowse/core/util'
import Base1DView from '@jbrowse/core/util/Base1DViewModel'
import { useTheme } from '@mui/material'
import Color from 'color'

// locals
import { LinearGenomeViewModel, HEADER_OVERVIEW_HEIGHT } from '..'
Expand All @@ -26,7 +27,7 @@ export default function SVGHeader({
const assemblyName = assemblyNames.length > 1 ? '' : assemblyNames[0]
const assembly = assemblyManager.get(assemblyName)
const theme = useTheme()

const c = Color(theme.palette.text.primary).hex()
const overview = Base1DView.create({
displayedRegions: JSON.parse(JSON.stringify(displayedRegions)),
interRegionPaddingWidth: 0,
Expand Down Expand Up @@ -55,15 +56,10 @@ export default function SVGHeader({
...last,
coord: last.reversed ? last.start : last.end,
}) || 0
const c = +showCytobands * cytobandHeight
const y = +showCytobands * cytobandHeight
return (
<g id="header">
<text
x={0}
y={fontSize}
fontSize={fontSize}
fill={theme.palette.text.primary}
>
<text x={0} y={0} dominantBaseline="hanging" fontSize={fontSize} fill={c}>
{assemblyName}
</text>

Expand All @@ -84,10 +80,10 @@ export default function SVGHeader({
</g>
) : null}

<g transform={`translate(0 ${fontSize + c})`}>
<g transform={`translate(0 ${fontSize + y})`}>
<SVGScalebar model={model} fontSize={fontSize} />
</g>
<g transform={`translate(0 ${rulerHeight + c})`}>
<g transform={`translate(0 ${rulerHeight + y})`}>
<SVGRuler model={model} fontSize={fontSize} />
</g>
</g>
Expand Down
Expand Up @@ -7,6 +7,7 @@ import { makeTicks } from '../util'

import { LinearGenomeViewModel } from '..'
import SVGRegionSeparators from './SVGRegionSeparators'
import Color from 'color'

type LGV = LinearGenomeViewModel

Expand All @@ -29,19 +30,20 @@ function Ruler({
}) {
const ticks = makeTicks(start, end, bpPerPx, major, minor)
const theme = useTheme()
const c = Color(theme.palette.text.secondary).hex()
return (
<>
{ticks.map(tick => {
const x = (reversed ? end - tick.base : tick.base - start) / bpPerPx
return (
<line
key={tick.base}
key={'tick-' + tick.base}
x1={x}
x2={x}
y1={0}
y2={tick.type === 'major' ? 6 : 4}
strokeWidth={1}
stroke={theme.palette.text.secondary}
stroke={c}
/>
)
})}
Expand All @@ -53,11 +55,11 @@ function Ruler({
(reversed ? end - tick.base : tick.base - start) / bpPerPx
return (
<text
key={`label-${tick.base}`}
x={x - 3}
y={7 + 11}
key={`label-${tick.base}`}
fontSize={11}
fill={theme.palette.text.primary}
fill={c}
>
{getTickDisplayStr(tick.base + 1, bpPerPx)}
</text>
Expand All @@ -82,6 +84,7 @@ export default function SVGRuler({
} = model
const renderRuler = contentBlocks.length < 5
const theme = useTheme()
const c = Color(theme.palette.text.primary).hex()
return (
<>
<SVGRegionSeparators model={model} height={30} />
Expand All @@ -98,12 +101,7 @@ export default function SVGRuler({
</defs>
<g transform={`translate(${offset} 0)`}>
<g clipPath={`url(#${clipid})`}>
<text
x={4}
y={fontSize}
fontSize={fontSize}
fill={theme.palette.text.primary}
>
<text x={4} y={fontSize} fontSize={fontSize} fill={c}>
{refName}
</text>
<g transform="translate(0 20)">
Expand Down
@@ -1,6 +1,7 @@
import React from 'react'
import { getBpDisplayStr } from '@jbrowse/core/util'
import { useTheme } from '@mui/material'
import Color from 'color'
import { LinearGenomeViewModel } from '..'

type LGV = LinearGenomeViewModel
Expand All @@ -20,35 +21,21 @@ export default function SVGScalebar({
const displayBp = getBpDisplayStr(totalBp)
const x0 = Math.max(-offsetPx, 0)
const x1 = x0 + totalWidthPx
const c = Color(theme.palette.text.secondary).hex()
const x = x0 + (x1 - x0) / 2
const y = fontSize
return (
<>
<line
x1={x0}
x2={x1}
y1={10}
y2={10}
stroke={theme.palette.text.secondary}
/>
<line
x1={x0}
x2={x0}
y1={5}
y2={15}
stroke={theme.palette.text.secondary}
/>
<line
x1={x1}
x2={x1}
y1={5}
y2={15}
stroke={theme.palette.text.secondary}
/>
<line x1={x0} x2={x1} y1={10} y2={10} stroke={c} />
<line x1={x0} x2={x0} y1={5} y2={15} stroke={c} />
<line x1={x1} x2={x1} y1={5} y2={15} stroke={c} />
<text
x={x0 + (x1 - x0) / 2}
y={fontSize * 2}
x={x}
y={y}
textAnchor="middle"
dominantBaseline="hanging"
fontSize={fontSize}
fill={theme.palette.text.primary}
fill={c}
>
{displayBp}
</text>
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 130aa25

Please sign in to comment.