Skip to content

Commit eac523d

Browse files
committed
fix: review findings
1 parent b31da18 commit eac523d

28 files changed

Lines changed: 10130 additions & 517 deletions

docs/docusaurus.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ const config = {
122122
DrawerSection: 'Drawer/DrawerSection',
123123
},
124124
FAB: {
125-
FloatingActionButton: 'FAB/FloatingActionButton',
126-
ExtendedFloatingActionButton: 'FAB/ExtendedFloatingActionButton',
127-
FloatingActionButtonMenu: 'FAB/FloatingActionButtonMenu',
125+
FAB: 'FAB/FAB',
126+
FABExtended: 'FAB/Extended',
127+
FABMenu: 'FAB/Menu',
128128
},
129129
IconButton: {
130130
IconButton: 'IconButton/IconButton',

docs/src/components/BannerExample.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useColorMode } from '@docusaurus/theme-common';
88
import {
99
Avatar,
1010
Button,
11-
FloatingActionButton,
11+
FAB,
1212
DarkTheme,
1313
LightTheme,
1414
ProgressBar,
@@ -83,9 +83,9 @@ const BannerExample = () => {
8383
<Button icon="camera" mode="contained" onPress={() => {}}>
8484
Press me
8585
</Button>
86-
<FloatingActionButton icon="plus" size="default" onPress={() => {}} />
87-
<FloatingActionButton icon="plus" size="medium" onPress={() => {}} />
88-
<FloatingActionButton icon="plus" size="large" onPress={() => {}} />
86+
<FAB icon="plus" size="default" onPress={() => {}} />
87+
<FAB icon="plus" size="medium" onPress={() => {}} />
88+
<FAB icon="plus" size="large" onPress={() => {}} />
8989
<Avatar.Text label="MD" />
9090
<Avatar.Icon icon="folder" />
9191
</Stack>

example/src/Examples/ActivityIndicatorExample.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import * as React from 'react';
22
import { StyleSheet, View } from 'react-native';
33

4-
import {
5-
ActivityIndicator,
6-
FloatingActionButton,
7-
List,
8-
Palette,
9-
} from 'react-native-paper';
4+
import { ActivityIndicator, FAB, List, Palette } from 'react-native-paper';
105

116
import ScreenWrapper from '../ScreenWrapper';
127

@@ -16,7 +11,7 @@ const ActivityIndicatorExample = () => {
1611
return (
1712
<ScreenWrapper style={styles.container}>
1813
<View style={styles.row}>
19-
<FloatingActionButton
14+
<FAB
2015
icon={animating ? 'pause' : 'play'}
2116
onPress={() => setAnimating(!animating)}
2217
/>

example/src/Examples/AppbarExample.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Platform, StyleSheet, View } from 'react-native';
44
import { useNavigation } from '@react-navigation/native';
55
import {
66
Appbar,
7-
FloatingActionButton,
7+
FAB,
88
List,
99
Palette,
1010
RadioButton,
@@ -23,7 +23,6 @@ const MORE_ICON = Platform.OS === 'ios' ? 'dots-horizontal' : 'dots-vertical';
2323
const MEDIUM_FAB_HEIGHT = 56;
2424

2525
const AppbarExample = () => {
26-
// @ts-ignore
2726
const navigation = useNavigation('Appbar');
2827

2928
const [showLeftIcon, setShowLeftIcon] = React.useState(true);
@@ -83,7 +82,7 @@ const AppbarExample = () => {
8382

8483
const renderFAB = () => {
8584
return (
86-
<FloatingActionButton
85+
<FAB
8786
icon="plus"
8887
onPress={() => {}}
8988
style={[styles.fab, { top: (height - MEDIUM_FAB_HEIGHT) / 2 }]}

example/src/Examples/BannerExample.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ import {
88
View,
99
} from 'react-native';
1010

11-
import {
12-
Banner,
13-
FloatingActionButton,
14-
Palette,
15-
useTheme,
16-
} from 'react-native-paper';
11+
import { Banner, FAB, Palette, useTheme } from 'react-native-paper';
1712

1813
import ScreenWrapper from '../ScreenWrapper';
1914

@@ -62,11 +57,7 @@ const BannerExample = () => {
6257
))}
6358
</View>
6459
</ScreenWrapper>
65-
<FloatingActionButton
66-
icon="eye"
67-
style={styles.fab}
68-
onPress={() => setVisible(!visible)}
69-
/>
60+
<FAB icon="eye" style={styles.fab} onPress={() => setVisible(!visible)} />
7061
<Banner
7162
onLayout={handleLayout}
7263
actions={[

example/src/Examples/FABExample.tsx

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ import {
1111
import {
1212
Chip,
1313
Divider,
14-
ExtendedFloatingActionButton,
15-
FloatingActionButton,
16-
FloatingActionButtonMenu,
17-
FloatingActionButtonSize,
18-
FloatingActionButtonVariant,
14+
FAB,
15+
FABSize,
16+
FABVariant,
1917
List,
2018
Switch,
2119
Text,
@@ -25,27 +23,31 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
2523

2624
type FabType = 'icon' | 'extended' | 'extendedTransforming' | 'menu';
2725
type FabPosition = 'start' | 'center' | 'end';
26+
type FabColor = FABVariant | 'custom';
2827

2928
// Pixels of scroll change required to flip the transforming FAB. Avoids
3029
// flicker from sub-pixel scroll jitter at the top of the list.
3130
const SCROLL_DELTA_THRESHOLD = 4;
3231

32+
const CUSTOM_CONTAINER_COLOR = '#E91E63';
33+
3334
const justifyContentByPosition = {
3435
start: 'flex-start',
3536
center: 'center',
3637
end: 'flex-end',
3738
} as const satisfies Record<FabPosition, 'flex-start' | 'center' | 'flex-end'>;
3839

39-
const variants: FloatingActionButtonVariant[] = [
40+
const variants: FabColor[] = [
4041
'primary',
4142
'secondary',
4243
'tertiary',
4344
'tonalPrimary',
4445
'tonalSecondary',
4546
'tonalTertiary',
47+
'custom',
4648
];
4749

48-
const sizes: FloatingActionButtonSize[] = ['default', 'medium', 'large'];
50+
const sizes: FABSize[] = ['default', 'medium', 'large'];
4951

5052
const types: FabType[] = ['icon', 'extended', 'extendedTransforming', 'menu'];
5153

@@ -96,9 +98,11 @@ const FABExample = () => {
9698
const { colors } = useTheme();
9799
const insets = useSafeAreaInsets();
98100

99-
const [variant, setVariant] =
100-
React.useState<FloatingActionButtonVariant>('tonalPrimary');
101-
const [size, setSize] = React.useState<FloatingActionButtonSize>('medium');
101+
const [variant, setVariant] = React.useState<FabColor>('tonalPrimary');
102+
const activeVariant = variant === 'custom' ? undefined : variant;
103+
const activeContainerColor =
104+
variant === 'custom' ? CUSTOM_CONTAINER_COLOR : undefined;
105+
const [size, setSize] = React.useState<FABSize>('medium');
102106
const [type, setType] = React.useState<FabType>('icon');
103107
const [position, setPosition] = React.useState<FabPosition>('end');
104108
const [showFab, setShowFab] = React.useState<boolean>(true);
@@ -188,19 +192,21 @@ const FABExample = () => {
188192
]}
189193
>
190194
{type === 'icon' && (
191-
<FloatingActionButton
195+
<FAB
192196
icon="pencil"
193-
variant={variant}
197+
variant={activeVariant}
198+
containerColor={activeContainerColor}
194199
size={size}
195200
visible={showFab}
196201
onPress={() => {}}
197202
/>
198203
)}
199204
{(type === 'extended' || type === 'extendedTransforming') && (
200-
<ExtendedFloatingActionButton
205+
<FAB.Extended
201206
icon="pencil"
202207
label="Compose"
203-
variant={variant}
208+
variant={activeVariant}
209+
containerColor={activeContainerColor}
204210
size={size}
205211
expanded={type === 'extended' ? true : transformingExpanded}
206212
visible={showFab}
@@ -209,36 +215,24 @@ const FABExample = () => {
209215
)}
210216
</View>
211217
{type === 'menu' ? (
212-
<FloatingActionButtonMenu
218+
<FAB.Menu
213219
expanded={menuExpanded}
214220
onDismiss={() => setMenuExpanded(false)}
215-
horizontalAlignment={position}
216-
button={
217-
<FloatingActionButton
218-
icon="pencil"
219-
variant={variant}
220-
size={size}
221-
visible={showFab}
222-
onPress={() => setMenuExpanded(true)}
223-
/>
224-
}
225-
>
226-
<FloatingActionButtonMenu.Item
227-
icon="email"
228-
label="Send"
229-
onPress={() => {}}
230-
/>
231-
<FloatingActionButtonMenu.Item
232-
icon="bell"
233-
label="Remind me"
234-
onPress={() => {}}
235-
/>
236-
<FloatingActionButtonMenu.Item
237-
icon="star"
238-
label="Favorite"
239-
onPress={() => {}}
240-
/>
241-
</FloatingActionButtonMenu>
221+
alignment={position}
222+
trigger={{
223+
icon: 'pencil',
224+
variant: activeVariant,
225+
containerColor: activeContainerColor,
226+
size,
227+
visible: showFab,
228+
onPress: () => setMenuExpanded(true),
229+
}}
230+
items={[
231+
{ icon: 'email', label: 'Send', onPress: () => {} },
232+
{ icon: 'bell', label: 'Remind me', onPress: () => {} },
233+
{ icon: 'star', label: 'Favorite', onPress: () => {} },
234+
]}
235+
/>
242236
) : null}
243237
</View>
244238
);

example/src/Examples/TeamDetails.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
Chip,
1919
Divider,
2020
IconButton,
21-
FloatingActionButton,
21+
FAB,
2222
PaperProvider,
2323
} from 'react-native-paper';
2424
import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -116,12 +116,7 @@ const News = () => {
116116
</Card>
117117
</View>
118118
</ScreenWrapper>
119-
<FloatingActionButton
120-
icon="magnify"
121-
onPress={() => {}}
122-
visible
123-
style={styles.fab}
124-
/>
119+
<FAB icon="magnify" onPress={() => {}} visible style={styles.fab} />
125120
</>
126121
);
127122
};

example/src/Examples/TooltipExample.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Avatar,
88
Banner,
99
Chip,
10-
FloatingActionButton,
10+
FAB,
1111
IconButton,
1212
List,
1313
ToggleButton,
@@ -149,7 +149,7 @@ const TooltipExample = () => {
149149
</ScreenWrapper>
150150
<View style={styles.fabContainer}>
151151
<Tooltip title="Press Me">
152-
<FloatingActionButton icon="plus" onPress={() => {}} />
152+
<FAB icon="plus" onPress={() => {}} />
153153
</Tooltip>
154154
</View>
155155
</>

src/babel/__fixtures__/rewrite-imports/code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
PaperProvider,
44
BottomNavigation,
55
Button,
6-
FloatingActionButton,
6+
FAB,
77
Appbar,
88
Palette,
99
NonExistent,

src/babel/__fixtures__/rewrite-imports/output.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import PaperProvider from "react-native-paper/lib/module/core/PaperProvider";
33
import BottomNavigation from "react-native-paper/lib/module/components/BottomNavigation/BottomNavigation";
44
import Button from "react-native-paper/lib/module/components/Button/Button";
5-
import FloatingActionButton from "react-native-paper/lib/module/components/FAB/FloatingActionButton";
5+
import FAB from "react-native-paper/lib/module/components/FAB";
66
import Appbar from "react-native-paper/lib/module/components/Appbar";
77
import { Palette } from "react-native-paper/lib/module/theme/tokens";
88
import { NonExistent, NonExistentSecond as Stuff, LightTheme } from "react-native-paper/lib/module/index.js";

0 commit comments

Comments
 (0)