fix: some details in sidebar and button components

This commit is contained in:
marcelines 2023-01-16 17:21:57 +00:00
parent 98e9c1850d
commit 0d56feb24b
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
3 changed files with 36 additions and 30 deletions

View File

@ -30,7 +30,13 @@ function App() {
</div> </div>
<main id="main"> <main id="main">
<div>topbar</div> <Stack
backgroundColor="$background"
justifyContent="center"
alignItems="center"
>
<Paragraph weight="semibold">Topbar</Paragraph>
</Stack>
<div> <div>
<Stack width="100%" height="100%" backgroundColor="$background"> <Stack width="100%" height="100%" backgroundColor="$background">
<Stack <Stack
@ -54,6 +60,7 @@ function App() {
Theme selected - {theme}{' '} Theme selected - {theme}{' '}
</Paragraph> </Paragraph>
<Button <Button
type="positive"
onPress={() => setTheme(theme === 'dark' ? 'light' : 'dark')} onPress={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
> >
Toogle theme Toogle theme
@ -62,7 +69,13 @@ function App() {
</Stack> </Stack>
</Stack> </Stack>
</div> </div>
<div>composer</div> <Stack
backgroundColor="$background"
justifyContent="center"
alignItems="center"
>
<Paragraph weight="semibold">Composer</Paragraph>
</Stack>
</main> </main>
</div> </div>
</TamaguiProvider> </TamaguiProvider>

View File

@ -1,15 +1,9 @@
import { Stack, styled, Text } from '@tamagui/core' import { styled, Text } from '@tamagui/core'
import { ButtonFrame } from 'tamagui'
import type { GetProps } from '@tamagui/core' import type { GetProps } from '@tamagui/core'
// import { Button} from 'react-native'
// import { Button as RNButton } from 'react-native' const Base = styled(ButtonFrame, {
// setupReactNative({ Button: RNButton })
// import type { GetProps} from '@tamagui/core';
const Base = styled(Stack, {
// tag: 'button', // tag: 'button',
cursor: 'pointer', cursor: 'pointer',
@ -17,26 +11,27 @@ const Base = styled(Stack, {
display: 'inline-flex', display: 'inline-flex',
paddingHorizontal: 16, paddingHorizontal: 16,
paddingVertical: 10, paddingVertical: 10,
animation: 'fast',
variants: { variants: {
type: { type: {
primary: { primary: {
backgroundColor: 'hsla(229, 71%, 57%, 1)', backgroundColor: '$primary',
hoverStyle: { backgroundColor: 'hsla(229, 54%, 45%, 1)' }, hoverStyle: { backgroundColor: '$primaryHover' },
pressStyle: { backgroundColor: 'hsla(229, 54%, 45%, 1)' }, pressStyle: { backgroundColor: '$primaryHover' },
}, },
positive: { positive: {
backgroundColor: 'hsla(174, 63%, 40%, 1)', backgroundColor: '$success',
hoverStyle: { backgroundColor: 'hsla(174, 63%, 34%, 1)' }, hoverStyle: { backgroundColor: '$successHover' },
pressStyle: { backgroundColor: 'hsla(174, 63%, 34%, 1)' }, pressStyle: { backgroundColor: '$successHover' },
}, },
}, },
} as const, } as const,
}) })
const ButtonText = styled(Text, { const ButtonText = styled(Text, {
color: 'rgb(255, 255, 255)', fontFamily: '$inter',
textAlign: 'center', textAlign: 'center',
color: '$white',
}) })
type BaseProps = GetProps<typeof Base> type BaseProps = GetProps<typeof Base>
@ -49,7 +44,9 @@ interface Props {
const Button = (props: Props) => { const Button = (props: Props) => {
const { type = 'primary', children, onPress } = props const { type = 'primary', children, onPress } = props
console.log(onPress)
console.log('Button', type)
return ( return (
<Base type={type} onPress={onPress}> <Base type={type} onPress={onPress}>
<ButtonText>{children}</ButtonText> <ButtonText>{children}</ButtonText>
@ -58,4 +55,3 @@ const Button = (props: Props) => {
} }
export { Button } export { Button }
// const Button =

View File

@ -1,12 +1,9 @@
import { Stack, styled, Text } from '@tamagui/core' import { Stack } from '@tamagui/core'
import { Avatar } from '../avatar' import { Avatar } from '../avatar'
import { Button } from '../button' import { Button } from '../button'
import { Image } from '../image' import { Image } from '../image'
import { Heading, Paragraph } from '../typography'
const Name = styled(Text, {})
const Desc = styled(Text, {})
interface Props { interface Props {
name: string name: string
@ -18,7 +15,7 @@ const _Sidebar = (props: Props) => {
const { name, description, membersCount } = props const { name, description, membersCount } = props
return ( return (
<Stack backgroundColor="rgb(255,255,255)"> <Stack backgroundColor="$background" minHeight={'calc(100vh - 2px)'}>
<Image <Image
src="https://images.unsplash.com/photo-1584475784921-d9dbfd9d17ca?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80" src="https://images.unsplash.com/photo-1584475784921-d9dbfd9d17ca?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80"
width={350} width={350}
@ -28,7 +25,7 @@ const _Sidebar = (props: Props) => {
paddingHorizontal={16} paddingHorizontal={16}
paddingBottom={16} paddingBottom={16}
marginTop={-16} marginTop={-16}
backgroundColor="rgb(255,255,255)" backgroundColor="$background"
borderTopLeftRadius={16} borderTopLeftRadius={16}
borderTopRightRadius={16} borderTopRightRadius={16}
zIndex={10} zIndex={10}
@ -39,9 +36,9 @@ const _Sidebar = (props: Props) => {
size={56} size={56}
/> />
</Stack> </Stack>
<Name marginBottom={16}>{name}</Name> <Heading marginBottom={16}>{name}</Heading>
<Desc marginBottom={12}>{description}</Desc> <Paragraph marginBottom={12}>{description}</Paragraph>
<Desc marginBottom={12}>{membersCount}</Desc> <Paragraph marginBottom={12}>{membersCount}</Paragraph>
<Button>Request to join community</Button> <Button>Request to join community</Button>
</Stack> </Stack>
</Stack> </Stack>