@planningcenter/olio-react-native
v0.1.1
Published
Components and utilities for the react-native space
Downloads
227
Readme
Olio is a component library that is being developed for sharing mobile components across multiple React Native apps. It is meant to be hodgepodge of components and other shared concerns, which is why it’s named “olio”.
“Olio” definition:
- a highly spiced stew of various meats and vegetables originating from Spain and Portugal.
- a miscellaneous collection of things.
Installation
npm install @planningcenter/olio-react-native
RichTextEditor
Our rich text editor is powered by trix and react-native-webview. It's a zero configuration text editor that works offline and is version controlled.
import { RichTextEditor } from '@planningcenter/olio-react-native'
const [value, setValue] = useState('')
<RichTextEditor value={value} onChange={setValue} />
DevTools
In order to use the menu, you will need to do the following:
Install
@planningcenter/olio-react-native
In a main file (e.g. app.js), add the following:
import { DevTools } from '@planningcenter/olio-react-native' function App() { ... return ( ... <DevTools /> ) }
IMPORTANT: Make sure that this is only added once to an app as initializing it multiple times could lead to issues in development
Tools
There are a few tools that you can use to help with the development process. To add a tool to the menu, you simply need to import that tool into your file and add it under the DevTools component.
LogSection
This tool allows you to filter out certain console logs. You can filter by log types (e.g. log, warn, error) or by message regexes. Filters can be combined to better control your console outputs. You will need to import and call useLogManager
around app initialization to get the filters to work without having to open the dev tools menu.
Example
import { DevTools, useLogManager } from '@planningcenter/olio-react-native'
export default function MyDevTools() {
useLogManager()
return (
<DevTools>
<DevTools.LogSection />
</DevTools>
)
}
NavigationSection
This tool allows you to jump to a specific screen immediately instead of trying to find a link to that screen. This requires an onNavigate
function that takes in a routeName and routeParams to determine how to handle navigation.
Example
import { DevTools } from '@planningcenter/olio-react-native'
import { useNavigation } from '@react-navigation/native'
export default function MyDevTools() {
const navigation = useNavigation()
return (
<DevTools>
<DevTools.NavigationSection onNavigate={navigation.navigate} />
</DevTools>
)
}
RequestSection
This tool allows you to override certain urls with custom responses. This can be useful for debugging when certain requests fail, testing different responses, and mocking endpoints that don't exist yet. You will need to import and call useRequestManager
around app initialization to get the overrides to work without having to open the dev tools menu.
Example
import { DevTools, useRequestManager } from '@planningcenter/olio-react-native'
export default function MyDevTools() {
useRequestManager()
return (
<DevTools>
<DevTools.RequestSection />
</DevTools>
)
}
StorageSection
This tool allows you to copy values stored in AsyncStorage to help you debug what certain values are.
Example
import { DevTools } from '@planningcenter/olio-react-native'
export default function MyDevTools() {
return (
<DevTools>
<DevTools.StorageSection />
</DevTools>
)
}
Custom tools
If you would like to create a custom tool, all you need to do is add children inside the DevTool component. You can use the following components to have a more consistent look
- Section (wrapper for new tools)
- Button
- Heading
- Icon
- Switch
- Text
- TextInput
For example, if you wanted to create a tool that tests alert, you could do something like this:
import { Alert, Text, View } from 'react-native'
import { DevTools } from '@planningcenter/olio-react-native'
...
const [value, setValue] = useState('')
<DevTools settings={mySettings}>
<DevTools.Section title="Alert Test">
<Text>Enter text to send alert</Text>
<View style={{ flexDirection: 'row', alignItems: 'center', columnGap: 8 }}>
<DevTools.TextInput value={value} onChangeText={setValue} />
<DevTools.Button text="Send" onPress={() => Alert.alert(value)} />
</View>
</DevTools.Section>
</DevTools>
...
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library