Skip to content

Components for reacting to pseudo-classes and observable styles in React Native

License

Notifications You must be signed in to change notification settings

seeyouin2x5x/expo-style-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@expo/style-utils

Components for reacting to pseudo-classes and observable styles in React Native.

Installation

yarn add @expo/style-utils

Usage

Import the library into your JavaScript file:

import { Hoverable, Resizable } from '@expo/style-utils';

You can wrap a function or a component.

import React, { Component } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { Hoverable } from '@expo/style-utils';

const createLogger = (...msg) => () => {
  console.log(...msg);
};

class App extends Component {
  render() {
    return (
      <View>
        <Hoverable onHoverIn={createLogger('start hover')} onHoverOut={createLogger('end hover')}>
          {isHovered => (
            <TouchableOpacity accessible style={{ backgroundColor: isHovered ? '#333' : '#fff' }}>
              <Text>Welcome to React</Text>}
            </TouchableOpacity>
          )}
        </Hoverable>
      </View>
    );
  }
}

Observe window resize events.

return (
  <Resizable>
    {layout => <View style={{ width: layout.width / 2, height: layout.width / 2 }} />}
  </Resizable>
);

About

Components for reacting to pseudo-classes and observable styles in React Native

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published