Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes of dark-theme and values in docs #6058

Merged
merged 10 commits into from
Jun 11, 2024
2 changes: 1 addition & 1 deletion packages/docs-reanimated/src/css/colors.css
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@

/* Versions dropdown */
--swm-dropdown-versions-background: var(--swm-off-white);
--swm-dropdown-versions-item: var(--swm-off-white);
--swm-dropdown-versions-item: var(--swm-navy-light-100);
--swm-dropdown-versions-item-border: var(--swm-purple-light-40);
--swm-dropdown-versions-item-background: var(--swm-purple-light-20);

Expand Down
18 changes: 17 additions & 1 deletion packages/docs-reanimated/src/css/overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,23 @@ table thead tr {
font-size: var(--swm-h1-font-size);
}

/* TODO: Remove after @swmansion-t-rex-ui 0.0.10 patch */
/* TODO: Remove after @swmansion-t-rex-ui 0.0.11 patch */
button[class*='DocSearch-Button'] {
margin: 0 !important;
}

/* versions dropdown on landing */

[class*='plugin-pages'] [class*='dropdown--right'] > a:first-child {
color: var(--swm-off-white) !important;
}

[class*='plugin-pages'] [class*='dropdown__menu'] a:hover {
color: var(--swm-dropdown-versions-item-hover) !important;
}

/* examples sidebar */

[class*='plugin-blog'] [class*='sidebar'] {
background-color: transparent;
}
6 changes: 5 additions & 1 deletion packages/docs-reanimated/src/examples/DecayBasic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from 'react-native-gesture-handler';

const SIZE = 120;
const BOUNDARY_OFFSET = 50;

export default function App() {
const offset = useSharedValue<number>(0);
Expand All @@ -31,7 +32,10 @@ export default function App() {
offset.value = withDecay({
velocity: event.velocityX,
rubberBandEffect: true,
clamp: [-(width.value / 2) + SIZE / 2, width.value / 2 - SIZE / 2],
clamp: [
-(width.value / 2) + SIZE / 2 + BOUNDARY_OFFSET,
width.value / 2 - SIZE / 2 - BOUNDARY_OFFSET,
],
});
// highlight-end
});
Expand Down
32 changes: 20 additions & 12 deletions packages/docs-reanimated/static/examples/BottomSheet.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { useColorScheme } from '@mui/material';
import {
Pressable,
SafeAreaView,
Expand All @@ -16,6 +17,7 @@ import Animated, {
} from 'react-native-reanimated';

function BottomSheet({ isOpen, toggleSheet, duration = 500, children }) {
const { colorScheme } = useColorScheme();
const height = useSharedValue(0);
const progress = useDerivedValue(() =>
withTiming(isOpen.value ? 0 : 1, { duration })
Expand All @@ -25,6 +27,10 @@ function BottomSheet({ isOpen, toggleSheet, duration = 500, children }) {
transform: [{ translateY: progress.value * 2 * height.value }],
}));

const backgroundColorSheetStyle = {
backgroundColor: colorScheme === 'light' ? '#f8f9ff' : '#272B3C',
};

const backdropStyle = useAnimatedStyle(() => ({
opacity: 1 - progress.value,
zIndex: isOpen.value
Expand All @@ -41,7 +47,7 @@ function BottomSheet({ isOpen, toggleSheet, duration = 500, children }) {
onLayout={(e) => {
height.value = e.nativeEvent.layout.height;
}}
style={[sheetStyles.sheet, sheetStyle]}>
style={[sheetStyles.sheet, sheetStyle, backgroundColorSheetStyle]}>
{children}
</Animated.View>
</>
Expand All @@ -50,7 +56,6 @@ function BottomSheet({ isOpen, toggleSheet, duration = 500, children }) {

const sheetStyles = StyleSheet.create({
sheet: {
backgroundColor: '#f8f9ff',
padding: 16,
paddingRight: '2rem',
paddingLeft: '2rem',
Expand All @@ -71,12 +76,18 @@ const sheetStyles = StyleSheet.create({
});

export default function App() {
const { colorScheme } = useColorScheme();
const isOpen = useSharedValue(false);

const toggleSheet = () => {
isOpen.value = !isOpen.value;
};

const contentStyle = {
color: colorScheme === 'light' ? '#001a72' : '#f8f9ff',
textDecorationColor: colorScheme === 'light' ? '#001a72' : '#f8f9ff',
};

return (
<SafeAreaView style={styles.container}>
<View style={styles.safeArea}>
Expand All @@ -87,14 +98,16 @@ export default function App() {
<View style={styles.flex} />
</View>
<BottomSheet isOpen={isOpen} toggleSheet={toggleSheet}>
<Text style={styles.bottomSheetContent}>
<Animated.Text style={contentStyle}>
Discover the indispensable convenience of a bottom sheet in mobile
app. Seamlessly integrated, it provides quick access to supplementary
features and refined details.
</Text>
</Animated.Text>
<View style={styles.buttonContainer}>
<Pressable style={styles.bottomSheetButton}>
<Text style={styles.bottomSheetButtonText}>Read more</Text>
<Pressable style={[styles.bottomSheetButton]}>
<Text style={[styles.bottomSheetButtonText, contentStyle]}>
Read more
</Text>
</Pressable>
</View>
</BottomSheet>
Expand Down Expand Up @@ -136,15 +149,10 @@ const styles = StyleSheet.create({
flexDirection: 'row',
alignItems: 'center',
gap: 8,
borderBottomWidth: 1,
borderBottomColor: '#001a72',
paddingBottom: 2,
},
bottomSheetButtonText: {
fontWeight: 600,
color: '#001a72',
},
bottomSheetContent: {
color: '#001a72',
textDecorationLine: 'underline',
},
});
28 changes: 22 additions & 6 deletions packages/docs-reanimated/static/examples/SectionList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FlashList } from '@shopify/flash-list';
import React, { useRef, useState } from 'react';
import { useColorScheme } from '@mui/material';
import { Pressable, StyleSheet, Text, View, SafeAreaView } from 'react-native';
import Animated, {
useAnimatedStyle,
Expand Down Expand Up @@ -105,16 +106,27 @@ const TableOfContentsElement = ({
visibleIndex,
sectionCardsRef,
}) => {
const { colorScheme } = useColorScheme();
const style = useSelectedStyle(visibleIndex, index);

const tableOfContentsElementTextStyle = {
color: colorScheme === 'light' ? '#001a72' : '#f8f9ff',
borderBottomColor: colorScheme === 'light' ? '#001a72' : '#f8f9ff',
};

return (
<Pressable
onPress={() => {
sectionCardsRef.current?.scrollToIndex({ index, animated: true });
visibleIndex.value = index;
}}
style={sectionListStyles.tableOfContentsElement}>
<Animated.Text style={[style, sectionListStyles.tableOfContentsElement]}>
style={[sectionListStyles.tableOfContentsElement]}>
<Animated.Text
style={[
style,
sectionListStyles.tableOfContentsElement,
tableOfContentsElementTextStyle,
]}>
{item}
</Animated.Text>
</Pressable>
Expand Down Expand Up @@ -184,9 +196,7 @@ const sectionListStyles = StyleSheet.create({
},
tableOfContentsElement: {
padding: 4,
color: '#001a72',
marginHorizontal: 4,
borderBottomColor: '#001a72',
margin: 8,
overflow: 'hidden',
},
Expand All @@ -201,6 +211,7 @@ const SectionCards = ({
sectionCardsRef,
tableOfContentsRef,
}) => {
const { colorScheme } = useColorScheme();
const heights = sections.map((_) => SECTION_HEIGHT);

const getOffsetStarts = () =>
Expand All @@ -226,10 +237,16 @@ const SectionCards = ({
}
};

const sectionNameStyle = useAnimatedStyle(() => ({
color: colorScheme === 'light' ? '#001a72' : '#f8f9ff',
}));

const renderItem = ({ item }) => {
return (
<View>
<Text style={sectionCardStyles.header}> {item.name}</Text>
<Animated.Text style={[sectionCardStyles.header, sectionNameStyle]}>
{item.name}
</Animated.Text>
<SectionCardsElement>
<Text style={sectionCardStyles.content}>{item.content}</Text>
</SectionCardsElement>
Expand Down Expand Up @@ -287,7 +304,6 @@ const sectionCardStyles = StyleSheet.create({
borderRadius: 24,
},
header: {
color: '#001a72',
textAlign: 'center',
fontSize: 24,
fontWeight: 'bold',
Expand Down