Skip to content

Commit

Permalink
responsive logo
Browse files Browse the repository at this point in the history
  • Loading branch information
LunatiqueCoder committed Jan 14, 2023
1 parent 253ed30 commit 7d08593
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions template/src/components/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import React from 'react';
import {SolitoImage} from 'solito/image';
import {Platform, useColorScheme} from 'react-native';
import {useLink} from 'solito/link';
import {Button, useMedia} from 'tamagui';
import {Button, useMedia, useThemeName} from 'tamagui';
import {tokens} from '@tamagui/theme-base';

const logoMediaQuery = (size: keyof typeof tokens.size) => {
const dimensions = {
width: tokens.size[size].val,
height: tokens.size[size].val,
};

// might be fixed by: https://github.com/nandorojo/solito/pull/268
return Platform.OS === 'web'
? dimensions
: {
style: dimensions,
};
};
const logoMediaQuery = (size: keyof typeof tokens.size) => ({
width: tokens.size[size].val,
height: tokens.size[size].val,
});

export const Logo = () => {
const theme = useThemeName();
const media = useMedia();
const colorScheme = useColorScheme() || 'light';
const linkProps = useLink({
href: '/',
});
Expand All @@ -34,9 +24,11 @@ export const Logo = () => {
icon={
<SolitoImage
priority
src={`/images/logo_${colorScheme}.png`}
src={`/images/logo_${theme}.png`}
alt="logo"
resizeMode="contain"
sizes="(max-width: 600px) 400px,
800px"
{...logoMediaQuery(8)}
{...(media.gtSm && {
...logoMediaQuery(9),
Expand Down

0 comments on commit 7d08593

Please sign in to comment.