Skip to content

Commit eaf2af1

Browse files
authored
Merge pull request #17 from Snapchat/clholgat/corebutton-font-indexpicker-web
Add CoreButton font override and tighten web IndexPicker
2 parents 5461b7b + 63bc9c0 commit eaf2af1

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

valdi_modules/widgets/src/components/button/CoreButton.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ export interface CoreButtonViewModel {
7878
*/
7979
icon?: Asset | string;
8080
text?: string;
81+
/**
82+
* Optional label font override (Valdi "family size [weight]" string).
83+
* Defaults to the font for the chosen `sizing`.
84+
*/
85+
font?: string;
8186
loading?: boolean;
8287
disabled?: boolean;
8388
/**
@@ -247,7 +252,9 @@ export class CoreButton extends StatefulComponent<CoreButtonViewModel, CoreButto
247252
const sidesSize = sizingOption.sides;
248253
const separatorSize = sizingOption.separator;
249254
const verticalPad = sizingOption.verticalPad;
250-
const textFont = viewModel.disableAccessibilityFontScaling ? sizingOption.nonDynamicFont : sizingOption.font;
255+
const textFont =
256+
viewModel.font ??
257+
(viewModel.disableAccessibilityFontScaling ? sizingOption.nonDynamicFont : sizingOption.font);
251258
const borderWidth = viewModel.borderWidth ?? sizingOption.border;
252259

253260
const rootRadius = minHeight / 2;

valdi_modules/widgets/web/src/WidgetsWeb.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,24 @@ function createIndexPickerFactory(): ViewFactory {
120120
return (container: HTMLElement): AttributeHandler => {
121121
container.style.display = 'flex';
122122
container.style.alignItems = 'center';
123-
container.style.justifyContent = 'center';
123+
container.style.justifyContent = 'stretch';
124124
container.style.pointerEvents = 'auto';
125+
// Explicit height prevents WebValdiCustomView from applying the 80px default min-height.
126+
container.style.height = '32px';
127+
container.style.minHeight = '0';
125128

126129
const select = document.createElement('select');
127-
select.style.fontSize = '16px';
128-
select.style.padding = '8px';
130+
select.style.fontFamily = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
131+
select.style.fontSize = '13px';
132+
select.style.padding = '4px 8px';
129133
select.style.border = '1px solid #ccc';
130134
select.style.borderRadius = '6px';
131135
select.style.cursor = 'pointer';
132-
select.style.minWidth = '120px';
136+
select.style.minWidth = '0';
137+
select.style.width = '100%';
138+
select.style.height = '100%';
139+
select.style.maxWidth = '100%';
140+
select.style.boxSizing = 'border-box';
133141
select.style.pointerEvents = 'auto';
134142
container.appendChild(select);
135143

0 commit comments

Comments
 (0)