Skip to content

Conversation

@nrcaz
Copy link

@nrcaz nrcaz commented Jan 11, 2024

Context:

My app is using a dark theme, the text by default is black, having the possibility to set a default font theme instead of rewriting default components would be nice

Solution:

Added a new props called theme which can take most text props for all text block types

 <PortableText value={value} theme={{normal: {color: 'white', fontFamily: 'Arial'}, h1: {color: 'white', fontFamily: 'Arial', fontSize: 32, fontWeight: "700"}}} />

I had to be able to specify fontWeight since on Android not controlling the weight can mess up with the fontFamily.

Since i didnt wanted to create breaking change with the use of defaultComponents i had to create a new function getDefaultComponentsWithTheme

PS: also fixed a typescript issue for locating types file due to index.d.ts file not being specified in package.json

@nrcaz nrcaz changed the title feature: allows user to specify default font theme proposal: feature: allows user to specify default font theme Jan 11, 2024
@nrcaz nrcaz changed the title proposal: feature: allows user to specify default font theme proposal: feature: allows user to specify font theme without having to override all components Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant