Skip to content

Commit

Permalink
ADD: customizable icon sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
fileformat committed Aug 6, 2024
1 parent c440336 commit bab66c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ You can use this as a viewer from any website by passing the correct query strin
* `backUrl` - destination for the Exit button
* `border` - border: one of "none", "dash", "thin" or "thick"
* `bg` - background: a hex color (like "#abc123", but note that the "#" has to be escaped to "%23") or one of the [standard images](public/images/backgrounds/) (without the ".png" extension)
* `url` - URL of the SVG file
* `sizes` - comma-separated list of sizes for the icon view
* `url` - (*required*) URL of the SVG file
* `zoom` - zoom level: a number or "max"

## License
Expand Down
16 changes: 15 additions & 1 deletion app/routes/view[.]html/IconList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { VStack, Stack, Text, useBreakpointValue, StackDirection } from "@chakra-ui/react";
import { useSearchParams } from "@remix-run/react";


const sizes = [ 16, 24, 32, 48, 64, 96, 128 ]
const defaultSizes = "16,24,32,48,64,96,128";

interface ICardProps {
imageCss: Record<string, string>;
Expand Down Expand Up @@ -37,13 +38,26 @@ type VHSettings = {
styles: object;
}

function getSizes(urlSizes: string): number[] {

if (!/[0-9]+(,[0-9]+)*/.test(urlSizes)) {
urlSizes = defaultSizes;
}
const strSizes = urlSizes.split(',');
return strSizes.map((size) => parseInt(size));
}


function IconList({
display,
imageCss,
url,
}: IProps) {

const [searchParams] = useSearchParams();

const sizes = getSizes(searchParams.get('sizes') || defaultSizes);

const vhsettings:VHSettings = useBreakpointValue({
base: { direction: 'column', spacing: 4, styles: { "position": "absolute", "top": "4px"}},
lg: { direction: 'row', spacing: 12, styles: {}},
Expand Down

0 comments on commit bab66c8

Please sign in to comment.