Skip to content

Commit

Permalink
feat: add z-index scale
Browse files Browse the repository at this point in the history
  • Loading branch information
tigranpetrossian committed Nov 14, 2024
1 parent 253dc13 commit 7361358
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion apps/mobile/src/app/(home)/generating-wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function GeneratingWalletScreen() {
bottom={height / 2}
left={0}
right={0}
zIndex={10}
zIndex="10"
justifyContent="center"
alignItems="center"
>
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/app/(home)/recover-wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default function RecoverWallet() {
{!hidePasteButton && (
<Button
onPress={pasteFromClipboard}
style={{ position: 'absolute', bottom: 12, right: 12, zIndex: 100 }}
style={{ position: 'absolute', bottom: 12, right: 12, zIndex: 20 }}
buttonState="default"
title={t({
id: 'recover_wallet.paste_button',
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/components/draggable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function Draggable({
const animatedStyles = useAnimatedStyle(() => ({
transform: [{ translateY: translationY.value }, { scale: zoom.value }],
position: isAnimatedShared.value ? 'absolute' : 'relative',
zIndex: isAnimatedShared.value ? 100 : 1,
zIndex: isAnimatedShared.value ? 20 : 1,
width: '100%',
top: isAnimatedShared.value ? thisItemPosition.value.y : 0,
left: isAnimatedShared.value ? thisItemPosition.value.x : 0,
Expand Down
10 changes: 2 additions & 8 deletions apps/mobile/src/components/headers/header.layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ export function HeaderLayout({
py="3"
px="3"
>
<Box
alignItems="flex-start"
flexGrow={1}
height="100%"
justifyContent="center"
zIndex={100}
>
<Box alignItems="flex-start" flexGrow={1} height="100%" justifyContent="center" zIndex="20">
{leftElement}
</Box>
<Box
Expand All @@ -56,7 +50,7 @@ export function HeaderLayout({
>
{centerElement}
</Box>
<Box alignItems="flex-end" flexGrow={1} height="100%" justifyContent="center" zIndex={100}>
<Box alignItems="flex-end" flexGrow={1} height="100%" justifyContent="center" zIndex="20">
{rightElement}
</Box>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/components/toast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function Toast({ toastRef }: ToastProps) {
alignSelf="center"
gap="3"
flexDirection="row"
zIndex={9999}
zIndex="100"
justifyContent="center"
alignItems="center"
testID={TestId.toastContainer}
Expand Down
1 change: 1 addition & 0 deletions packages/panda-preset/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { tokens } from './tokens';
import { textStyles } from './typography';

export default definePreset({
name: 'leather',
theme: {
extend: {
semanticTokens,
Expand Down
7 changes: 6 additions & 1 deletion packages/panda-preset/src/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { defineTokens } from '@pandacss/dev';

import { tokens as leatherTokens } from '@leather.io/tokens';
import { tokens as leatherTokens, zIndices } from '@leather.io/tokens';

import { colors } from './colors';

function transformZIndices(zIndices: Record<string, number>) {
return Object.fromEntries(Object.entries(zIndices).map(([key, value]) => [key, { value }]));
}

export const tokens = defineTokens({
...leatherTokens,
colors,
zIndex: transformZIndices(zIndices),
});
1 change: 1 addition & 0 deletions packages/tokens/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export type { AllThemePalette } from './colors';
export { keyframes } from './keyframes';
export { semanticTokens } from './semantic-tokens';
export { getWebTextVariants, getMobileTextVariants } from './typography';
export { zIndices } from './z-indices';
export { tokens } from './tokens';
15 changes: 15 additions & 0 deletions packages/tokens/src/z-indices.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const zIndices = {
'-1': -1,
'0': 0,
'10': 10,
'20': 20,
'30': 30,
'40': 40,
'50': 50,
'60': 60,
'70': 70,
'80': 80,
'90': 90,
'100': 100,
max: 9999,
};
4 changes: 2 additions & 2 deletions packages/tokens/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'tsup';
import { type Options, defineConfig } from 'tsup';

export default defineConfig({
export default defineConfig(<Options>{
entry: ['src/index.ts'],
sourcemap: true,
clean: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function SheetHeader({ title, icon, onPressSupport }: SheetHeaderProps) {
</Box>
</Box>
<Box alignItems="flex-end" flex={1}>
<TouchableOpacity onPress={onPressSupport} zIndex={10}>
<TouchableOpacity onPress={onPressSupport} zIndex="10">
<QuestionCircleIcon variant="small" />
</TouchableOpacity>
</Box>
Expand Down
5 changes: 2 additions & 3 deletions packages/ui/src/theme-native/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ColorSchemeName } from 'react-native';

import { ThemeProvider as ThemeProviderRestyle, createTheme } from '@shopify/restyle';

import { colorThemes, getMobileTextVariants } from '@leather.io/tokens';
import { colorThemes, getMobileTextVariants, zIndices } from '@leather.io/tokens';

const textVariants = getMobileTextVariants();

Expand All @@ -27,8 +27,7 @@ export function generateTheme(colorScheme: ColorSchemeName) {
round: 9999,
},
textVariants,
// Temporary workaround for type errors. TODO: Add a zIndex scale.
zIndices: undefined,
zIndices: zIndices,

Check warning on line 30 in packages/ui/src/theme-native/theme.tsx

View workflow job for this annotation

GitHub Actions / lint-eslint

Expected property shorthand

Check warning on line 30 in packages/ui/src/theme-native/theme.tsx

View workflow job for this annotation

GitHub Actions / lint-eslint

Expected property shorthand
breakpoints: {},
});
}
Expand Down

0 comments on commit 7361358

Please sign in to comment.