diff --git a/example/.rnstorybook/stories/Atoms/Text/Text.stories.tsx b/example/.rnstorybook/stories/Atoms/Text/Text.stories.tsx index 538d7d3..418f94e 100644 --- a/example/.rnstorybook/stories/Atoms/Text/Text.stories.tsx +++ b/example/.rnstorybook/stories/Atoms/Text/Text.stories.tsx @@ -139,3 +139,20 @@ export const Truncated: Story = { 'This is a very long text that should be truncated after one line because numberOfLines is set to 1', }, }; + +export const InlineBold: Story = { + args: { + children: 'I agree to the **Terms & Privacy Policy**', + }, +}; + +export const InlineBoldVariants: Story = { + render: () => ( + + {'I agree to the **Terms & Privacy Policy**'} + {'**Bold** at the start of the sentence'} + {'Mix of **bold** and regular text here'} + {'**Multiple** bold **segments** in one text'} + + ), +}; diff --git a/example/App.tsx b/example/App.tsx new file mode 100644 index 0000000..6000249 --- /dev/null +++ b/example/App.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import { useFonts } from 'expo-font'; +import StorybookUI from './.rnstorybook'; + +export default function App() { + const [loaded] = useFonts({ + 'Geist-Light': require('./assets/fonts/Geist/ttf/Geist-Light.ttf'), + 'Geist-Regular': require('./assets/fonts/Geist/ttf/Geist-Regular.ttf'), + 'Geist-Medium': require('./assets/fonts/Geist/ttf/Geist-Medium.ttf'), + 'Geist-SemiBold': require('./assets/fonts/Geist/ttf/Geist-SemiBold.ttf'), + 'Geist-Bold': require('./assets/fonts/Geist/ttf/Geist-Bold.ttf'), + 'GeistMono-Regular': require('./assets/fonts/GeistMono/ttf/GeistMono-Regular.ttf'), + }); + + if (!loaded) return null; + + return ; +} diff --git a/example/assets/fonts/Geist/ttf/Geist-Bold.ttf b/example/assets/fonts/Geist/ttf/Geist-Bold.ttf new file mode 100644 index 0000000..fa18a85 Binary files /dev/null and b/example/assets/fonts/Geist/ttf/Geist-Bold.ttf differ diff --git a/example/assets/fonts/Geist/ttf/Geist-Light.ttf b/example/assets/fonts/Geist/ttf/Geist-Light.ttf new file mode 100644 index 0000000..57c3192 Binary files /dev/null and b/example/assets/fonts/Geist/ttf/Geist-Light.ttf differ diff --git a/example/assets/fonts/Geist/ttf/Geist-Medium.ttf b/example/assets/fonts/Geist/ttf/Geist-Medium.ttf new file mode 100644 index 0000000..4fe8124 Binary files /dev/null and b/example/assets/fonts/Geist/ttf/Geist-Medium.ttf differ diff --git a/example/assets/fonts/Geist/ttf/Geist-Regular.ttf b/example/assets/fonts/Geist/ttf/Geist-Regular.ttf new file mode 100644 index 0000000..bd8775f Binary files /dev/null and b/example/assets/fonts/Geist/ttf/Geist-Regular.ttf differ diff --git a/example/assets/fonts/Geist/ttf/Geist-SemiBold.ttf b/example/assets/fonts/Geist/ttf/Geist-SemiBold.ttf new file mode 100644 index 0000000..a81032e Binary files /dev/null and b/example/assets/fonts/Geist/ttf/Geist-SemiBold.ttf differ diff --git a/example/assets/fonts/GeistMono/ttf/GeistMono-Regular.ttf b/example/assets/fonts/GeistMono/ttf/GeistMono-Regular.ttf new file mode 100644 index 0000000..ba09031 Binary files /dev/null and b/example/assets/fonts/GeistMono/ttf/GeistMono-Regular.ttf differ diff --git a/example/assets/fonts/OFL.txt b/example/assets/fonts/OFL.txt new file mode 100644 index 0000000..61f6f4b --- /dev/null +++ b/example/assets/fonts/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font.git) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://openfontlicense.org + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. \ No newline at end of file diff --git a/example/index.ts b/example/index.ts index fb2c867..5fd059f 100644 --- a/example/index.ts +++ b/example/index.ts @@ -1,4 +1,4 @@ import { registerRootComponent } from 'expo'; -import StorybookUI from './.rnstorybook'; +import App from './App'; -registerRootComponent(StorybookUI); +registerRootComponent(App); diff --git a/example/package.json b/example/package.json index 3be3e75..a544715 100644 --- a/example/package.json +++ b/example/package.json @@ -18,6 +18,7 @@ "@storybook/addon-ondevice-controls": "^10.2.3", "@storybook/react-native": "^10.2.3", "expo": "~54.0.33", + "expo-font": "^55.0.6", "expo-status-bar": "~3.0.9", "lottie-react-native": "^7.3.6", "react": "19.1.0", diff --git a/src/components/Atoms/Text/hooks/useTextViewModel/index.ts b/src/components/Atoms/Text/hooks/useTextViewModel/index.ts index 97ca758..306137e 100644 --- a/src/components/Atoms/Text/hooks/useTextViewModel/index.ts +++ b/src/components/Atoms/Text/hooks/useTextViewModel/index.ts @@ -20,6 +20,5 @@ export const useTextViewModel = (props: PropsWithChildren) => { return { content, - textStyle: styles.text, }; }; diff --git a/src/components/Atoms/Text/index.tsx b/src/components/Atoms/Text/index.tsx index eac5bb5..1173c23 100644 --- a/src/components/Atoms/Text/index.tsx +++ b/src/components/Atoms/Text/index.tsx @@ -3,13 +3,16 @@ import type { PropsWithChildren } from 'react'; import React from 'react'; import { Text as TextRN } from 'react-native'; import { useTextViewModel } from './hooks'; +import { useStyles } from './styles'; export const Text: React.FC> = (props) => { const { numberOfLines } = props; - const { content, textStyle } = useTextViewModel(props); + + const styles = useStyles(props); + const { content } = useTextViewModel(props); return ( - + {content} ); diff --git a/src/components/Atoms/Text/styles.ts b/src/components/Atoms/Text/styles.ts index 45753ac..80a201b 100644 --- a/src/components/Atoms/Text/styles.ts +++ b/src/components/Atoms/Text/styles.ts @@ -15,7 +15,7 @@ export const useStyles = (props: ITextProps) => { const fontFamily = Tokens.fontFamily({ key: 'sans' })[weight]; const fontSize = Tokens.fontSize({ key: size }); - const boldFontFamily = Tokens.fontFamily({ key: 'sans' }).bold; + const boldFontFamily = Tokens.fontFamily({ key: 'sans' }).semibold; return StyleSheet.create({ text: { @@ -24,6 +24,7 @@ export const useStyles = (props: ITextProps) => { textAlign: align, color: colors[color], }, + boldText: { fontFamily: boldFontFamily, }, diff --git a/yarn.lock b/yarn.lock index e185328..91c19ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6863,6 +6863,19 @@ __metadata: languageName: node linkType: hard +"expo-font@npm:^55.0.6": + version: 55.0.6 + resolution: "expo-font@npm:55.0.6" + dependencies: + fontfaceobserver: "npm:^2.1.0" + peerDependencies: + expo: "*" + react: "*" + react-native: "*" + checksum: 10c0/accd823ca5ab4fb8ab3faf665414a22a0e991119ee2f99a35acf06b55b0dc0436d426515edf889114d1b7ebe5cd79094ef711ec052fc5f176e0abe56453d175d + languageName: node + linkType: hard + "expo-font@npm:~14.0.11": version: 14.0.11 resolution: "expo-font@npm:14.0.11" @@ -11765,6 +11778,7 @@ __metadata: "@storybook/react-native": "npm:^10.2.3" "@types/react": "npm:~19.1.0" expo: "npm:~54.0.33" + expo-font: "npm:^55.0.6" expo-status-bar: "npm:~3.0.9" lottie-react-native: "npm:^7.3.6" react: "npm:19.1.0"