Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add root font size to the grill integration config #364

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export type GrillConfig = {
/** Option to make the iframe open chat room (a channel) directly */
channel?: Channel
order?: string[]
/** The root font size of the . You can change it if you want all font sizes to be smaller/bigger. Default root font size is 1rem (16px). For example, you can change it to 0.875rem to make it 14px, or just straight up use 14px. */
rootFontSize?: string
/** The theme of the chat. If omitted, it will use the system preferences or user's last theme used in <https://grill.chat> */
theme?: Theme
/** A function that will be called when the iframe is created. You can use this to customize the iframe attributes. */
Expand Down
14 changes: 13 additions & 1 deletion src/providers/ConfigProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type State = {
theme?: Theme
order?: string[]
channels?: Set<string>
rootFontSize?: string
enableBackButton?: boolean
enableLoginButton?: boolean
enableInputAutofocus?: boolean
Expand Down Expand Up @@ -61,7 +62,16 @@ export function ConfigProvider({ children }: { children: any }) {
}, [state])

return (
<ConfigContext.Provider value={state}>{children}</ConfigContext.Provider>
<>
<ConfigContext.Provider value={state}>{children}</ConfigContext.Provider>
{state.rootFontSize && (
<style jsx global>{`
:root {
font-size: ${state.rootFontSize};
}
`}</style>
)}
</>
)
}

Expand All @@ -85,6 +95,7 @@ const schemaGetter = {
const theme = getUrlQuery('theme')
const order = getUrlQuery('order')
const channels = getUrlQuery('channels')
const rootFontSize = getUrlQuery('rootFontSize')

const enableBackButton = getUrlQuery('enableBackButton')
const enableLoginButton = getUrlQuery('enableLoginButton')
Expand All @@ -101,6 +112,7 @@ const schemaGetter = {
order: usedOrder,
channels: usedChannels.size > 0 ? usedChannels : undefined,
theme: validateStringConfig(theme, ['dark', 'light']),
rootFontSize,
enableBackButton: validateStringConfig(
enableBackButton,
['true', 'false'],
Expand Down