Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kristerkari/react-native-css-modules-with-typescript-example
A simple example app that shows how you can use CSS modules + Typescript with React Native and React (for browser)
https://github.com/kristerkari/react-native-css-modules-with-typescript-example
css css-modules demo-app example react-native sass ts typescript
Last synced: 21 days ago
JSON representation
A simple example app that shows how you can use CSS modules + Typescript with React Native and React (for browser)
- Host: GitHub
- URL: https://github.com/kristerkari/react-native-css-modules-with-typescript-example
- Owner: kristerkari
- Created: 2018-02-24T22:21:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-16T13:05:47.000Z (over 1 year ago)
- Last Synced: 2023-07-16T14:24:58.627Z (over 1 year ago)
- Topics: css, css-modules, demo-app, example, react-native, sass, ts, typescript
- Language: Java
- Homepage:
- Size: 7.9 MB
- Stars: 18
- Watchers: 5
- Forks: 11
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React Native + CSS modules + Typescript
![Platform - Android, iOS and Web](https://img.shields.io/badge/platform-Android%20%7C%20iOS%20%7C%20Web-blue.svg)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github)A simple example app that shows how you can use CSS modules + Typescript with React Native and React (for browser).
Have a look at the [src](/src) folder to see code examples.
**Quick links:** **[Features](#example-app-features)** • **[Screenshots](#screenshots)** • **[Try it](#try-it)** • **[Documentation](https://github.com/kristerkari/react-native-css-modules#documentation)**
## Example App features
#### React Native and Web
- :package: Automatically generates Typescript typings (`.d.ts` files) for CSS and Sass files using [react-native-typed-css-transformer](https://github.com/kristerkari/react-native-typed-css-transformer), [react-native-typed-sass-transformer
](https://github.com/kristerkari/react-native-typed-sass-transformer) and Webpack's [typings-for-css-modules-loader](https://github.com/Jimdo/typings-for-css-modules-loader).
- :package: [Uses custom Typescript `@types/react-native` package with support for className property](https://github.com/kristerkari/react-native-types-for-css-modules).
- :tada: Allows `className` and `style` properties to be used on React Native elements such as `` or ``.
- :fire: CSS Hot loading (live reloading).
- :ok_hand: Uses [Sass](src/Buttons.scss) and [CSS](src/ProfileCard.css) for styles
- :mag: [Custom stylelint config for React Native CSS modules](https://github.com/kristerkari/stylelint-config-react-native-css-modules)#### React Native specific
- :package: Uses [React Native CSS modules](https://github.com/kristerkari/react-native-css-modules)
- :globe_with_meridians: [Platform specific file extensions](https://facebook.github.io/react-native/docs/platform-specific-code.html#platform-specific-extensions), e.g. `styles.ios.css`, `styles.android.css`, `styles.native.css`.#### Web specific
- :package: Uses [Webpack](https://webpack.js.org/) + [CSS modules](https://github.com/css-modules/css-modules).
- :wrench: Uses [React Native for Web](https://github.com/necolas/react-native-web) to make most React Native elements work in the browser.## Supported Browsers
- Mobile: Android Stock browser (4.4-5.x), Android Chrome, iOS Safari 8+
- Desktop: Firefox, Chrome, Safari## Try it
### Step 1: Install depencies to run React Native
Make sure that you have `react-native-cli` installed (`npm install -g react-native-cli`) and [XCode](https://developer.apple.com/xcode/) (for iOS development) / [Android Studio](https://developer.android.com/studio/index.html) (for Android development) installed and working.
- Go to "Building Projects with Native Code" tab and follow the guide: https://facebook.github.io/react-native/docs/getting-started.html
### Step 2: Clone the repo and move to project
```sh
git clone [email protected]:kristerkari/react-native-css-modules-with-typescript-example.git
cd react-native-css-modules-with-typescript-example
```### Step 3: Install example app's dependencies
NodeJS packages:
```sh
yarn install
```and CocoaPods for iOS:
```sh
cd ios && pod install
```### Step 4: Run React Native packager
You can open a new terminal tab to run React Native's packager.
```sh
yarn start
```### Step 5: Run app on Android, iOS or Web
First make sure that your Android emulator or iOS simulator is working, then:
```sh
yarn ios
```or
```sh
yarn android
```or
```sh
yarn web
```Web app can be accessed by opening `http://localhost:8080` in a browser.
## Screenshots
**iOS - Android - Web**