Skip to content

Commit

Permalink
fix: fix project errors regarding eslint and config
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakeoon committed Feb 1, 2022
1 parent 504e3a6 commit cb2a5c9
Show file tree
Hide file tree
Showing 10 changed files with 291 additions and 70 deletions.
2 changes: 1 addition & 1 deletion example/src/DrawerItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const DrawerItems = ({ toggleTheme, toggleRTL, isRTL, isDarkTheme }: Props) => {

const _setDrawerItem = (index: number) => setDrawerItemIndex(index);

const { colors } = useTheme() | { colors: {} };
const { colors } = useTheme();

const _handleToggleRTL = () => {
toggleRTL();
Expand Down
2 changes: 1 addition & 1 deletion example/src/Examples/BannerExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PHOTOS = Array.from({ length: 24 }).map(
const BannerExample = () => {
const [visible, setVisible] = React.useState<boolean>(true);
const [useCustomTheme, setUseCustomTheme] = React.useState<boolean>(false);
const defaultTheme = useTheme() | { colors: {} };
const defaultTheme = useTheme();
const customTheme = {
...defaultTheme,
colors: {
Expand Down
2 changes: 1 addition & 1 deletion example/src/Examples/ButtonExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button, List, useTheme } from 'react-native-paper';
import ScreenWrapper from '../ScreenWrapper';

const ButtonExample = () => {
const { colors } = useTheme() | { colors: {} };
const { colors } = useTheme();

return (
<ScreenWrapper>
Expand Down
2 changes: 1 addition & 1 deletion example/src/Examples/ChipExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ScreenWrapper from '../ScreenWrapper';

const ChipExample = () => {
const [visible, setVisible] = React.useState<boolean>(false);
const { colors } = useTheme() | { colors: {} };
const { colors } = useTheme();

return (
<>
Expand Down
50 changes: 6 additions & 44 deletions example/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import { createDrawerNavigator } from '@react-navigation/drawer';
import {
Provider as PaperProvider,
DarkTheme,
DefaultTheme,
Theme,
DefaultTheme as LightTheme,
ThemeBase,
} from 'react-native-paper';
import App from './RootNavigator';
import DrawerItems from './DrawerItems';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import LightTheme from '../../src/styles/themes/v3/LightTheme';

// Add new typescript properties to the theme
declare global {
Expand All @@ -35,39 +34,6 @@ declare global {
const PERSISTENCE_KEY = 'NAVIGATION_STATE';
const PREFERENCES_KEY = 'APP_PREFERENCES';

const CustomDarkTheme = {
...DarkTheme,
colors: {
...DarkTheme.colors,
customColor: '#BADA55',
},
fonts: {
...DarkTheme.fonts,
superLight: { ...DarkTheme.fonts['light'] },
},
animation: {
...DarkTheme.animation,
customProperty: 1,
},
};

const CustomDefaultTheme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
customColor: '#BADA55',
},
fonts: {
...DefaultTheme.fonts,
superLight: { ...DefaultTheme.fonts['light'] },
},
userDefinedThemeProperty: '',
animation: {
...DefaultTheme.animation,
customProperty: 1,
},
};

export const PreferencesContext = React.createContext<any>(null);

const DrawerContent = () => {
Expand Down Expand Up @@ -95,7 +61,7 @@ export default function PaperExample() {
InitialState | undefined
>();

const [theme, setTheme] = React.useState<Theme>(CustomDefaultTheme);
const [theme, setTheme] = React.useState<ThemeBase>(LightTheme);
const [rtl, setRtl] = React.useState<boolean>(I18nManager.isRTL);

React.useEffect(() => {
Expand Down Expand Up @@ -125,9 +91,7 @@ export default function PaperExample() {

if (preferences) {
// eslint-disable-next-line react/no-did-mount-set-state
setTheme(
preferences.theme === 'dark' ? CustomDarkTheme : CustomDefaultTheme
);
setTheme(preferences.theme === 'dark' ? DarkTheme : LightTheme);

if (typeof preferences.rtl === 'boolean') {
setRtl(preferences.rtl);
Expand Down Expand Up @@ -167,9 +131,7 @@ export default function PaperExample() {
const preferences = React.useMemo(
() => ({
toggleTheme: () =>
setTheme((theme) =>
theme === CustomDefaultTheme ? CustomDarkTheme : CustomDefaultTheme
),
setTheme((theme) => (theme === LightTheme ? DarkTheme : LightTheme)),
toggleRtl: () => setRtl((rtl) => !rtl),
rtl,
theme,
Expand All @@ -182,7 +144,7 @@ export default function PaperExample() {
}

return (
<PaperProvider theme={LightTheme}>
<PaperProvider theme={theme}>
<SafeAreaProvider>
<PreferencesContext.Provider value={preferences}>
<React.Fragment>
Expand Down
261 changes: 261 additions & 0 deletions src/components/__tests__/Typography/__snapshots__/Text.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders every variant of Text with children as content 1`] = `
Array [
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
<Text
style={
Array [
Object {
"color": "#000000",
"fontFamily": "System",
"fontWeight": "400",
},
Object {
"textAlign": "left",
},
undefined,
]
}
>
Something rendered as a child content
</Text>,
]
`;
Loading

0 comments on commit cb2a5c9

Please sign in to comment.