Airframe GitHub Storybook

React Native getting started

Install @britishairways-ent/bagel-react-native, load the BA fonts, and render a screen. Each component's props are on its page, under the React Native library option. To work on the library itself, use Storybook in the bagel-react-native repository, below. The release pass runs in a separate app, on the React Native QA process.

The package is published to GitHub Packages, on the same registry as the web library. Create a personal access token and sign in with it, using the steps under With a javascript framework.

Point the @britishairways-ent scope at that registry. Add this to the .npmrc in the app:

Scope the British Airways packages to GitHub Packages
@britishairways-ent:registry=https://npm.pkg.github.com

Then install the library:

npm install @britishairways-ent/bagel-react-native

The app also needs these peers. Versions below are the minimums.

Always
react 18.2 or newer, and react-native 0.73 or newer.
react-native-safe-area-context 4.5 or newer. BaScreen reads its insets.
Icons and links
react-native-svg 15 or newer, for BaIcon and BaLink.
Animation
react-native-reanimated 3 or newer, for BaCarousel, BaCopyToClipboard, and BaDetails. An Expo app already includes the Reanimated Babel plugin. A bare app adds react-native-reanimated/plugin as the last plugin in babel.config.js. Reanimated 4 also needs a compatible react-native-worklets.
Copy to clipboard
@react-native-clipboard/clipboard 1.14 or newer, for BaCopyToClipboard.

To use the package from GitHub Actions, request access the same way as for the web package. See GitHub Actions.

Mylius Modern and Open Sans ship on bagelFontAssets. Load that map before rendering BaText, or the type falls back to the system font.

An Expo app uses expo-font:

Load the BA fonts before the first screen
import { useFonts } from 'expo-font';
import { bagelFontAssets } from '@britishairways-ent/bagel-react-native';

const [fontsLoaded] = useFonts(bagelFontAssets);
if (!fontsLoaded) return null;

A bare React Native app can use expo-font the same way, or pass those files to its own font loader.

Wrap the tree in SafeAreaProvider, then BaModeProvider. Put each screen in BaScreen, then BaPageSegment and BaContent. Omit theme. The screen and the segment follow the colour mode. Add BaScroll between the screen and the segments when the page scrolls. Scrolling is the next section.

A first screen with a heading and a button
import { useFonts } from 'expo-font';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import {
  BaButton,
  BaModeProvider,
  BaScreen,
  BaPageSegment,
  BaContent,
  BaText,
  bagelFontAssets,
} from '@britishairways-ent/bagel-react-native';

export default function App() {
  const [fontsLoaded] = useFonts(bagelFontAssets);
  if (!fontsLoaded) return null;

  return (
    <SafeAreaProvider>
      <BaModeProvider>
        <BaScreen>
          <BaPageSegment fill>
            <BaContent>
              <BaText variant="header28">Hello</BaText>
              <BaButton variant="primary" onPress={() => {}}>
                Continue
              </BaButton>
            </BaContent>
          </BaPageSegment>
        </BaScreen>
      </BaModeProvider>
    </SafeAreaProvider>
  );
}

Put BaScroll inside BaScreen, and the segments inside the scroll view. Page margin stays on BaPageSegment, so the scroll indicator sits on the screen edge. The scroll view is on ba-scroll.

On a screen under native bottom tabs, set safeAreaBottom={false} on BaScreen. BaScroll defaults contentInsetAdjustmentBehavior to automatic, so on iOS the system can inset for the home indicator and an overlaying tab bar.

A screen that scrolls its segments
<BaScreen>
  <BaScroll>
    <BaPageSegment>
      <BaContent>
        <BaText variant="body16">Your trip</BaText>
      </BaContent>
    </BaPageSegment>
  </BaScroll>
</BaScreen>

BaModeProvider follows the device. Light mode uses default (white). Dark mode uses midnight-700. Set the mode on ba-mode. The screen, scroll view, and segments are on ba-screen, ba-scroll, and ba-page-segment.

Set Expo userInterfaceStyle to "automatic". "light" keeps iOS in light mode, so the provider stays on the white theme.

Omit theme on a segment to follow the mode. Pass theme="sale" when that band should stay sale in both modes. Wrap neighbouring segments in BaPageSegmentGroup so matching themes share one block of padding.

A mode-following segment, then a sale segment
<BaScreen>
  <BaPageSegmentGroup>
    <BaPageSegment>
      <BaContent>
        <BaText variant="header28">Your trip</BaText>
      </BaContent>
    </BaPageSegment>
    <BaPageSegment theme="sale">
      <BaContent>
        <BaText variant="header20">Sale fares</BaText>
      </BaContent>
    </BaPageSegment>
  </BaPageSegmentGroup>
</BaScreen>

Storybook lives in the bagel-react-native repository and runs through the example/ app. It is where a component is built and reviewed while you work on the library. It is separate from the release pass, which runs in bagel-qa-react-native.

From the library repository:

npm install
Installs the library and the example app.
npm run build
Builds the package the example app loads.
npm run storybook
Starts Storybook for the example app.
npm run storybook:ios
Opens Storybook in the iOS Simulator.
npm run storybook:android
Opens Storybook in the Android Emulator.

Those scripts set EXPO_PUBLIC_STORYBOOK_ENABLED=true. Storybook has on-device controls for props such as theme and locale. The screen size is the simulator, emulator, or device you run it on.

Designing Developing Components BAgel helper Web QA React Native QA britishairways.com Careers Cookie policy