Skip to content

Make expand glyph size changing with density #104

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

Merged
merged 1 commit into from
Jun 16, 2024
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
23 changes: 21 additions & 2 deletions packages/components/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,36 @@ const parameters = {

const globalTypes = {
accent: {
name: 'Accent',
name: 'Accent color',
description: 'Theme accent color for components',
defaultValue: '#006CBE',
toolbar: {
title: 'Accent color',
icon: 'paintbrush',
// Array of plain string values or MenuItem shape (see below)
items: [
{ value: '#006CBE', right: '🔵', title: 'blue' },
{ value: '#DA1A5F', title: 'pink' },
{ value: '#f2c812', title: 'yellow' }
]
],
dynamicTitle: true
}
},
density: {
name: 'Density',
description: 'UI element density',
defaultValue: 0,
toolbar: {
title: 'Density',
icon: 'grow',
items: [
{ value: -4, title: 'xsmall' },
{ value: -2, title: 'small' },
{ value: 0, title: 'medium' },
{ value: 2, title: 'large' },
{ value: 4, title: 'xlarge' }
],
dynamicTitle: true
}
}
};
Expand Down
14 changes: 11 additions & 3 deletions packages/components/src/menu-item/menu-item.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
accentFillRest,
bodyFont,
controlCornerRadius,
density,
designUnit,
disabledOpacity,
focusStrokeWidth,
Expand All @@ -30,7 +31,8 @@ import {
neutralForegroundRest,
strokeWidth,
typeRampBaseFontSize,
typeRampBaseLineHeight
typeRampBaseLineHeight,
typeRampPlus1FontSize
} from '../design-tokens.js';
import {
DirectionalStyleSheetBehavior,
Expand Down Expand Up @@ -148,8 +150,8 @@ export const menuItemStyles: FoundationElementTemplate<

.expand-collapse-glyph {
/* TODO: adaptive typography https://github.com/microsoft/fast/issues/2432 */
width: 16px;
height: 16px;
width: calc((16 + ${density}) * 1px);
height: calc((16 + ${density}) * 1px);
fill: currentcolor;
}

Expand All @@ -170,6 +172,12 @@ export const menuItemStyles: FoundationElementTemplate<
/* TODO: adaptive typography https://github.com/microsoft/fast/issues/2432 */
width: 16px;
height: 16px;

/* Something like that would do if the typography is adaptive
font-size: inherit;
width: ${typeRampPlus1FontSize};
height: ${typeRampPlus1FontSize};
*/
}

:host(:hover) .start,
Expand Down
13 changes: 10 additions & 3 deletions packages/components/src/tree-item/tree-item.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import {
neutralForegroundRest,
strokeWidth,
typeRampBaseFontSize,
typeRampBaseLineHeight
typeRampBaseLineHeight,
typeRampPlus1FontSize
} from '../design-tokens.js';
import {
DirectionalStyleSheetBehavior,
Expand Down Expand Up @@ -211,8 +212,8 @@ export const treeItemStyles: FoundationElementTemplate<

.expand-collapse-glyph {
/* TODO: adaptive typography https://github.com/microsoft/fast/issues/2432 */
width: 16px;
height: 16px;
width: calc((16 + ${density}) * 1px);
height: calc((16 + ${density}) * 1px);
transition: transform 0.1s linear;

pointer-events: none;
Expand All @@ -229,6 +230,12 @@ export const treeItemStyles: FoundationElementTemplate<
/* TODO: adaptive typography https://github.com/microsoft/fast/issues/2432 */
width: 16px;
height: 16px;

/* Something like that would do if the typography is adaptive
font-size: inherit;
width: ${typeRampPlus1FontSize};
height: ${typeRampPlus1FontSize};
*/
}

.start {
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/utilities/storybook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export function withTheme(story: any, context: StoryContext): HTMLElement {
? StandardLuminance.DarkMode
: StandardLuminance.LightMode;

const density = context.globals.density;
theme.density = density;

const children = story();
if (typeof children === 'string') {
theme.insertAdjacentHTML('afterbegin', children);
Expand Down
Loading