Skip to content

Commit

Permalink
fix error with 'basis' fonts (fbsamples#205)
Browse files Browse the repository at this point in the history
* fix error with 'basis' fonts

* add flow typings
  • Loading branch information
distolma authored and frantic committed Apr 5, 2018
1 parent dcb8180 commit 805e3af
Show file tree
Hide file tree
Showing 18 changed files with 87 additions and 25 deletions.
2 changes: 2 additions & 0 deletions js/common/ActionsOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
* @flow
*/

"use strict";
Expand All @@ -39,6 +40,7 @@ const CONTAINER_HEIGHT = 126,
<ActionsOverlay />
============================================================================= */
class ActionsOverlay extends React.Component {
static __cards__;
static height = CONTAINER_HEIGHT;
static defaultProps = {
buttonContainerStyles: {
Expand Down
3 changes: 2 additions & 1 deletion js/common/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
* @flow
*/
"use strict";

Expand All @@ -29,7 +30,7 @@ type Props = {
count: number,
selectedIndex: number,
onSelectedIndexChange?: (index: number) => void,
renderCard: (index: number) => ReactElement,
renderCard: (index: number) => ReactElement<any>,
style?: any
};

Expand Down
7 changes: 5 additions & 2 deletions js/common/F8BackgroundRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
* @flow
*/
"use strict";

Expand All @@ -36,6 +37,8 @@ import resolveAssetSource from "resolveAssetSource";
* ==============================================================================
*/
class F8BackgroundRepeat extends React.Component {
static __cards__;

render() {
const { source, width, height } = this.props;
const img = resolveAssetSource(source);
Expand All @@ -60,7 +63,7 @@ class F8BackgroundRepeat extends React.Component {
);
}

renderRow(colsInRow, idx) {
renderRow(colsInRow: number, idx: number) {
const cols = [];
for (let i = 0; i < colsInRow; i++) {
cols.push(this.renderImage(i));
Expand All @@ -72,7 +75,7 @@ class F8BackgroundRepeat extends React.Component {
);
}

renderImage(idx) {
renderImage(idx: number) {
return <Image key={`bgRptImg${idx}`} source={this.props.source} />;
}
}
Expand Down
14 changes: 12 additions & 2 deletions js/common/F8Fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
* @flow
*/

"use strict";
Expand All @@ -27,11 +28,15 @@ import { Platform, Dimensions } from "react-native";
const DEVICE_SCALE = Dimensions.get("window").width / 375;

const DEFAULT_FONT = "helvetica";
const SECONDARY_FONT = Platform.OS === "android" ? "basis" : "helvetica";

/* utils ==================================================================== */

// get font name and weight
function fontWithWeight(family = DEFAULT_FONT, weight = "regular") {
function fontWithWeight(
family: string = DEFAULT_FONT,
weight: string = "regular"
): string {
return family;
}

Expand All @@ -40,7 +45,11 @@ function normalize(size: number): number {
}

// attempt to normalize x-platform line heights
function lineHeight(val = 1, scale = 1, normalized = true) {
function lineHeight(
val: number = 1,
scale: number = 1,
normalized: boolean = true
): number {
let adjusted = normalized ? normalize(val) : val;
return Math.round(Platform.OS === "android" ? adjusted * scale : adjusted);
}
Expand All @@ -50,6 +59,7 @@ function lineHeight(val = 1, scale = 1, normalized = true) {
export default {
default: DEFAULT_FONT,
helvetica: DEFAULT_FONT,
basis: SECONDARY_FONT,
h1: DEFAULT_FONT,
h2: DEFAULT_FONT,
h3: DEFAULT_FONT,
Expand Down
1 change: 1 addition & 0 deletions js/common/F8Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
* @flow
*/
"use strict";

Expand Down
48 changes: 38 additions & 10 deletions js/common/F8Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
* @flow
*/

"use strict";
Expand All @@ -34,43 +35,70 @@ import StyleSheet from "./F8StyleSheet";
// Text Elements
// =============================================================================

export function Text({ style, ...props }: Object): ReactElement {
export function Text({
style,
...props
}: Object): ReactElement<ReactNative.Text> {
return <ReactNative.Text style={[styles.text, style]} {...props} />;
}

export function Heading1({ style, ...props }: Object): ReactElement {
export function Heading1({
style,
...props
}: Object): ReactElement<ReactNative.Text> {
return <ReactNative.Text style={[styles.h1, style]} {...props} />;
}

export function Heading2({ style, ...props }: Object): ReactElement {
export function Heading2({
style,
...props
}: Object): ReactElement<ReactNative.Text> {
return <ReactNative.Text style={[styles.h2, style]} {...props} />;
}

export function Heading3({ style, ...props }: Object): ReactElement {
export function Heading3({
style,
...props
}: Object): ReactElement<ReactNative.Text> {
return <ReactNative.Text style={[styles.h3, style]} {...props} />;
}

export function Heading4({ style, ...props }: Object): ReactElement {
export function Heading4({
style,
...props
}: Object): ReactElement<ReactNative.Text> {
return <ReactNative.Text style={[styles.h4, style]} {...props} />;
}

export function Heading5({ style, ...props }: Object): ReactElement {
export function Heading5({
style,
...props
}: Object): ReactElement<ReactNative.Text> {
return <ReactNative.Text style={[styles.h5, style]} {...props} />;
}

export function Paragraph({ style, ...props }: Object): ReactElement {
export function Paragraph({
style,
...props
}: Object): ReactElement<ReactNative.Text> {
return <ReactNative.Text style={[styles.p, style]} {...props} />;
}

// export function Hyperlink({style, ...props}: Object): ReactElement {
// export function Hyperlink({style, ...props}: Object): ReactElement<ReactNative.Text> {
// return <ReactNative.Text style={[styles.a, style]} {...props} />;
// }

export function HeaderTitle({ style, ...props }: Object): ReactElement {
export function HeaderTitle({
style,
...props
}: Object): ReactElement<ReactNative.Text> {
return <ReactNative.Text style={[styles.headerTitle, style]} {...props} />;
}

export function HorizontalRule({ style, ...props }: Object): ReactElement {
export function HorizontalRule({
style,
...props
}: Object): ReactElement<ReactNative.Text> {
return <ReactNative.View style={[styles.hr, style]} {...props} />;
}

Expand Down
1 change: 1 addition & 0 deletions js/common/F8TimelineBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
* @flow
*/

import React from "react";
Expand Down
3 changes: 2 additions & 1 deletion js/common/F8Touchable.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
* @flow
*/

"use strict";
Expand All @@ -29,7 +30,7 @@ import {
Platform
} from "react-native";

function F8TouchableIOS(props: Object): ReactElement {
function F8TouchableIOS(props: Object): ReactElement<TouchableHighlight> {
return (
<TouchableHighlight
accessibilityTraits="button"
Expand Down
3 changes: 3 additions & 0 deletions js/common/LaunchScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
* @flow
*/
"use strict";

Expand All @@ -37,6 +38,8 @@ const WIN_WIDTH = Dimensions.get("window").width,
*/

class LaunchScreen extends React.Component {
static __cards__;

render() {
return (
<View style={[styles.container, this.props.style]}>
Expand Down
3 changes: 2 additions & 1 deletion js/common/LoginButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
* @flow
*/
"use strict";

Expand All @@ -31,7 +32,7 @@ class LoginButton extends React.Component {
props: {
style: any,
source?: string, // For Analytics
dispatch: (action: any) => Promise,
dispatch: (action: any) => Promise<any>,
onLoggedIn: ?() => void
};
state: {
Expand Down
5 changes: 4 additions & 1 deletion js/common/MessengerModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
* @flow
*/
"use strict";

Expand All @@ -41,6 +42,8 @@ const APP_STORE = "https://itunes.apple.com/us/app/messenger/id454638411",
============================================================================= */

class MessengerModal extends React.Component {
static __cards__;

render() {
return (
<F8Modal
Expand Down Expand Up @@ -88,7 +91,7 @@ class MessengerModal extends React.Component {
);
};

openAppStore = _ => {
openAppStore = () => {
const url = Platform.OS === "ios" ? APP_STORE : PLAY_STORE;
F8Linking.canOpenURL(url)
.then(supported => {
Expand Down
2 changes: 1 addition & 1 deletion js/filter/TopicItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const styles = StyleSheet.create({
justifyContent: "space-between"
},
title: {
fontFamily: F8Fonts.fontWithWeight("basis", "offWhite"),
fontFamily: F8Fonts.fontWithWeight(F8Fonts.basis, "offWhite"),
fontSize: 17,
color: "white",
flex: 1
Expand Down
8 changes: 8 additions & 0 deletions js/flow-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ declare var expect: any;
declare module "graphql" {
declare var exports: any;
}

declare module "react-native-linear-gradient" {
declare var exports: any;
}

declare module "resolveAssetSource" {
declare var exports: any;
}
2 changes: 1 addition & 1 deletion js/tabs/F8TabsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const styles = StyleSheet.create({
badgeText: {
backgroundColor: "transparent",
fontSize: 9,
fontFamily: F8Fonts.fontWithWeight("basis", "helveticaBold"),
fontFamily: F8Fonts.fontWithWeight(F8Fonts.basis, "helveticaBold"),
color: F8Colors.white,

ios: {
Expand Down
2 changes: 1 addition & 1 deletion js/tabs/demos/DemosCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const styles = StyleSheet.create({
},
day: {
color: F8Colors.yellow,
fontFamily: F8Fonts.fontWithWeight("basis", "helveticaBold"),
fontFamily: F8Fonts.fontWithWeight(F8Fonts.basis, "helveticaBold"),
fontSize: 13
},
time: {
Expand Down
4 changes: 2 additions & 2 deletions js/tabs/schedule/F8SessionDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ const styles = StyleSheet.create({
},
location: {
fontSize: 13,
fontFamily: F8Fonts.fontWithWeight("basis", "helveticaBold")
fontFamily: F8Fonts.fontWithWeight(F8Fonts.basis, "helveticaBold")
},
time: {
color: F8Colors.tangaroa,
fontFamily: F8Fonts.fontWithWeight("basis", "helveticaBold")
fontFamily: F8Fonts.fontWithWeight(F8Fonts.basis, "helveticaBold")
},
title: {
marginVertical: 15,
Expand Down
2 changes: 1 addition & 1 deletion js/tabs/schedule/GeneralScheduleView.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class GeneralScheduleView extends React.Component {
titleStyles={{ marginBottom: 5 }}
text={`Swipe ${dayDir} for Day ${otherDay}`.toUpperCase()}
textStyles={{
fontFamily: F8Fonts.fontWithWeight("basis", "helvetica"),
fontFamily: F8Fonts.fontWithWeight(F8Fonts.basis, "helvetica"),
color: F8Colors.colorWithAlpha("tangaroa", 0.5),
fontSize: 13
}}
Expand Down
2 changes: 1 addition & 1 deletion js/tabs/schedule/SessionsCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const styles = StyleSheet.create({
},
day: {
color: F8Colors.yellow,
fontFamily: F8Fonts.fontWithWeight("basis", "helveticaBold"),
fontFamily: F8Fonts.fontWithWeight(F8Fonts.basis, "helveticaBold"),
fontSize: 13,

android: {
Expand Down

0 comments on commit 805e3af

Please sign in to comment.