Skip to content

Commit

Permalink
Merge pull request #200 from ZeroGachis/feature/rew-313-design-review…
Browse files Browse the repository at this point in the history
…-ecran-liste-des-workspaces

Feature/rew 313 design review ecran liste des workspaces
  • Loading branch information
AdrienCasta authored Mar 6, 2024
2 parents b43dc9a + 1669b65 commit 483fd66
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Storybook/components/TopAppBar/TopAppBar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { StyleSheet, View } from 'react-native';
import { TopAppBar, Title } from '../../../src/components/topAppBar/TopAppBar';
import { Headline } from '../../../src/components/typography/Headline';

const asString = { value: 'menu' };
const asString = { value: 'Menu' };
const asButton = {
value: 'menu',
value: 'Menu',
onPress: () => {},
};
const asComponent = { value: <Headline size='h1'>Headline H1</Headline> };
Expand Down
32 changes: 25 additions & 7 deletions src/components/topAppBar/TopAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Headline } from '../typography/Headline';
import DeviceInfo from 'react-native-device-info';
import type { WithTestID } from 'src/shared/type';
import TopAppBarAction from './TopAppBarAction';
import {TopAppBarMenu} from "./Menu/TopAppBarMenu";
import TopAppBarMenuItem from "./Menu/TopAppBarMenuItem";
import { TopAppBarMenu } from './Menu/TopAppBarMenu';
import TopAppBarMenuItem from './Menu/TopAppBarMenuItem';

export interface Title {
value: ReactNode;
Expand All @@ -22,6 +22,7 @@ export type TopAppBarProps = WithTestID<{
action?: ReactNode;
}>;

const isTablet = DeviceInfo.isTablet();
// eslint-disable-next-line react/function-component-definition
export function TopAppBar({
size = 'small',
Expand All @@ -35,6 +36,12 @@ export function TopAppBar({

const styles = useStyles(size, style);

const headlineSize = isTablet
? 'h1'
: isTitleBelowTopAppBar(size)
? 'h3'
: 'h1';

return (
<Appbar.Header
mode={size}
Expand All @@ -52,13 +59,15 @@ export function TopAppBar({
<Appbar.Content
title={
typeof title.value === 'string' ? (
<Headline size='h2'>{title.value}</Headline>
<Headline size={headlineSize} style={styles.title}>
{title.value}
</Headline>
) : (
title.value
)
}
onPress={title.onPress}
style={styles.title}
style={styles.content}
/>
{action}
</Appbar.Header>
Expand All @@ -73,22 +82,31 @@ function useStyles(
style: TopAppBarProps['style'],
) {
const theme = useTheme();
const isTablet = DeviceInfo.isTablet();

return StyleSheet.create({
button: {
backgroundColor: 'rgba(145, 158, 171, 0.24)',
borderRadius: 18,
marginLeft: isTablet ? 12 : theme.sw.spacing.xs,
},
title: {
paddingTop: size === 'medium' ? 9 : 0,
content: {
paddingTop: isTitleBelowTopAppBar(size) ? 9 : 0,
paddingBottom: 0,
justifyContent: 'flex-start',
},
title: {
lineHeight: isTitleBelowTopAppBar(size) ? undefined : 32,
},
header: {
paddingHorizontal: 12,
paddingBottom: 0,
marginBottom: theme.sw.spacing.l,
backgroundColor: theme.sw.colors.neutral['50'],
...style,
},
});
}

function isTitleBelowTopAppBar(size: TopAppBarProps['size']) {
return (['medium', 'large'] as (typeof size)[]).includes(size);
}

0 comments on commit 483fd66

Please sign in to comment.