forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RN: Migrate
LogBoxInspectorHeader-test.js
from Shallow Renderer (fa…
…cebook#44978) Summary: Pull Request resolved: facebook#44978 Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended. Changelog: [Internal] Differential Revision: D58643059
- Loading branch information
1 parent
d8020da
commit 7eb95c9
Showing
4 changed files
with
107 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/react-native/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
import type {ImageSource} from '../../Image/ImageSource'; | ||
import type {LogLevel} from '../Data/LogBoxLog'; | ||
|
||
import Image from '../../Image/Image'; | ||
import StyleSheet from '../../StyleSheet/StyleSheet'; | ||
import LogBoxButton from './LogBoxButton'; | ||
import * as LogBoxStyle from './LogBoxStyle'; | ||
import * as React from 'react'; | ||
|
||
const backgroundForLevel = (level: LogLevel) => | ||
({ | ||
warn: { | ||
default: 'transparent', | ||
pressed: LogBoxStyle.getWarningDarkColor(), | ||
}, | ||
error: { | ||
default: 'transparent', | ||
pressed: LogBoxStyle.getErrorDarkColor(), | ||
}, | ||
fatal: { | ||
default: 'transparent', | ||
pressed: LogBoxStyle.getFatalDarkColor(), | ||
}, | ||
syntax: { | ||
default: 'transparent', | ||
pressed: LogBoxStyle.getFatalDarkColor(), | ||
}, | ||
})[level]; | ||
|
||
export default function LogBoxInspectorHeaderButton( | ||
props: $ReadOnly<{ | ||
disabled: boolean, | ||
image: ImageSource, | ||
level: LogLevel, | ||
onPress?: ?() => void, | ||
}>, | ||
): React.Node { | ||
return ( | ||
<LogBoxButton | ||
backgroundColor={backgroundForLevel(props.level)} | ||
onPress={props.disabled ? null : props.onPress} | ||
style={styles.button}> | ||
{props.disabled ? null : ( | ||
<Image source={props.image} style={styles.buttonImage} /> | ||
)} | ||
</LogBoxButton> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
button: { | ||
alignItems: 'center', | ||
aspectRatio: 1, | ||
justifyContent: 'center', | ||
marginTop: 5, | ||
marginRight: 6, | ||
marginLeft: 6, | ||
marginBottom: -8, | ||
borderRadius: 3, | ||
}, | ||
buttonImage: { | ||
height: 14, | ||
width: 8, | ||
tintColor: LogBoxStyle.getTextColor(), | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters