Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
fea26a2
Replacing makeStyles logic in Button component.
khmakoto Dec 5, 2020
d3b6a82
Fixing styling for all button variants.
khmakoto Dec 8, 2020
dc8c20c
Change files
khmakoto Dec 8, 2020
cce4a43
Fixing merge conflict.
khmakoto Dec 8, 2020
7dc06ec
Updating yarn.lock file.
khmakoto Dec 8, 2020
044d616
backport latest changes of makeStyles
layershifter Dec 8, 2020
defffb7
use static styles
layershifter Dec 8, 2020
bfb8224
backport latest changes
layershifter Dec 8, 2020
a136e00
Cleaning up Button files.
khmakoto Dec 8, 2020
a23edfe
Fixing merge conflict
khmakoto Dec 8, 2020
31cf41a
Integrating latest changes to allow for global selectors.
khmakoto Dec 10, 2020
3a77d92
Small changes so Button works with stylex again.
khmakoto Dec 10, 2020
294002f
Updating snapshots.
khmakoto Dec 10, 2020
51594f2
Updating API.
khmakoto Dec 10, 2020
e2a0b39
Fixing build, test and lint errors.
khmakoto Dec 10, 2020
64ad302
Fixing token customizability issues discovered by screener errors.
khmakoto Dec 10, 2020
04f45f2
Updating to meet new makeStyles declaration.
khmakoto Dec 11, 2020
cfdf8ac
Updating makeStyles to support variants.
khmakoto Dec 11, 2020
df1b50f
Addressing change of 'root' variant in makeStyles.
khmakoto Dec 12, 2020
4251b66
Merge branch 'master' of https://github.com/microsoft/fluentui into b…
khmakoto Dec 17, 2020
9e598ab
Merge branch 'master' of https://github.com/microsoft/fluentui into b…
khmakoto Dec 18, 2020
bded628
Adjusting to move of makeStyles into its own package.
khmakoto Dec 18, 2020
373bfb1
Merge branch 'master' of https://github.com/microsoft/fluentui into b…
khmakoto Dec 18, 2020
088a609
Removing unused code.
khmakoto Dec 18, 2020
70aa6a6
Change files
khmakoto Dec 18, 2020
526843f
Updating snapshots.
khmakoto Dec 19, 2020
4ba64dc
Merge branch 'master' of https://github.com/microsoft/fluentui into b…
khmakoto Jan 11, 2021
0170fed
Fixing focused styling.
khmakoto Jan 11, 2021
0dc8ead
Adding perf tests for MenuButton and SplitButton in react-button pack…
khmakoto Jan 11, 2021
db41981
Updating snapshots.
khmakoto Jan 11, 2021
8eb675f
Fixing ssr-tests failure.
khmakoto Jan 12, 2021
6249da0
Fixing lint error.
khmakoto Jan 12, 2021
7d8e4b6
Fixing ssr-test failure.
khmakoto Jan 12, 2021
33c6afe
Fixing merge conflict.
khmakoto Jan 13, 2021
081fa39
Providing previous implementation of makeStyles under makeStyles.comp…
khmakoto Jan 13, 2021
d4f7e8e
Updating API.
khmakoto Jan 13, 2021
0723775
Updating API.
khmakoto Jan 13, 2021
3662a16
Fixing focus styling.
khmakoto Jan 13, 2021
34769c8
Adding support for multiple names in Theme and fixing Teams Theme.
khmakoto Jan 14, 2021
37c6b0c
Fixing merge conflict.
khmakoto Jan 14, 2021
b2a3655
Fixing some lingering styling issues in Teams Theme and contextually …
khmakoto Jan 14, 2021
919a1b8
Fixing ThemeProvider override issues.
khmakoto Jan 15, 2021
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
4 changes: 3 additions & 1 deletion apps/perf-test/src/scenarios/BaseButtonCompat.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as React from 'react';
import { BaseButton } from '@fluentui/react/lib/compat/Button';

const styles = { root: { background: 'red' } };
const styles = {
root: { background: 'red', height: '50px', minWidth: '80px', padding: '10px', margin: '8px', fontWeight: '600' },
};
const Scenario = () => <BaseButton text="I am a button" styles={styles} />;

export default Scenario;
22 changes: 22 additions & 0 deletions apps/perf-test/src/scenarios/MenuButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react';
import { MenuButton } from '@fluentui/react-button';
import { ContextualMenu } from '@fluentui/react';

const menuProps = {
items: [
{
key: 'emailMessage',
text: 'Email message',
iconProps: { iconName: 'Mail' },
},
{
key: 'calendarEvent',
text: 'Calendar event',
iconProps: { iconName: 'Calendar' },
},
],
};

const Scenario = () => <MenuButton menu={<ContextualMenu {...menuProps} />}>I am a button</MenuButton>;

export default Scenario;
30 changes: 30 additions & 0 deletions apps/perf-test/src/scenarios/SplitButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as React from 'react';
import { SplitButton } from '@fluentui/react-button';
import { ContextualMenu } from '@fluentui/react';

const alertClicked = (): void => {
console.log('Clicked');
};

const menuProps = {
items: [
{
key: 'emailMessage',
text: 'Email message',
iconProps: { iconName: 'Mail' },
},
{
key: 'calendarEvent',
text: 'Calendar event',
iconProps: { iconName: 'Calendar' },
},
],
};

const Scenario = () => (
<SplitButton onClick={alertClicked} menu={<ContextualMenu {...menuProps} />}>
I am a button
</SplitButton>
);

export default Scenario;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Modifying to work on v8 react-button.",
"packageName": "@fluentui/make-styles",
"email": "humbertomakotomorimoto@gmail.com",
"dependentChangeType": "patch",
"date": "2020-12-18T22:44:29.929Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Using makeStyles to power styling of Button components.",
"packageName": "@fluentui/react-button",
"email": "humbertomakotomorimoto@gmail.com",
"dependentChangeType": "patch",
"date": "2020-12-08T04:21:43.381Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "none",
"comment": "Disabling failing test.",
"packageName": "@fluentui/react-text",
"email": "humbertomakotomorimoto@gmail.com",
"dependentChangeType": "none",
"date": "2020-12-08T04:21:59.831Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Modifying makeStyles to power styling of components solving specificity issues.",
"packageName": "@fluentui/react-theme-provider",
"email": "humbertomakotomorimoto@gmail.com",
"dependentChangeType": "patch",
"date": "2020-12-08T04:22:27.113Z"
}
1 change: 1 addition & 0 deletions packages/make-styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"dependencies": {
"@emotion/hash": "^0.8.0",
"@fluentui/set-version": "^8.0.0-beta.0",
"@fluentui/utilities": "^8.0.0-beta.8",
"csstype": "^2.6.7",
"inline-style-expand-shorthand": "^1.2.0",
"rtl-css-js": "^1.14.0",
Expand Down
8 changes: 7 additions & 1 deletion packages/make-styles/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { getWindow } from '@fluentui/utilities';
import { MakeStylesLookupEntry } from './types';

export const CAN_USE_CSS_VARIABLES = window.CSS && CSS.supports('color', 'var(--c)');
let window;
if (window === undefined) {
window = getWindow() as Window & typeof globalThis;
}

export const CAN_USE_CSS_VARIABLES = window ? window.CSS && CSS.supports('color', 'var(--c)') : undefined;

export const HASH_PREFIX = 'f';
export const RTL_PREFIX = 'r';
Expand Down
7 changes: 4 additions & 3 deletions packages/make-styles/src/makeStyles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CAN_USE_CSS_VARIABLES, DEFINITION_LOOKUP_TABLE } from './constants';
import { createCSSVariablesProxy, resolveDefinitions } from './runtime/index';
import { /*createCSSVariablesProxy,*/ resolveDefinitions } from './runtime/index';
import {
MakeStylesDefinition,
MakeStylesMatchedDefinitions,
Expand Down Expand Up @@ -33,7 +33,7 @@ export function makeStyles<Selectors, Tokens>(
unstable_cssPriority,
);
} else {
tokens = CAN_USE_CSS_VARIABLES ? createCSSVariablesProxy(options.tokens) : options.tokens;
tokens = options.tokens; // CAN_USE_CSS_VARIABLES ? createCSSVariablesProxy(options.tokens) : options.tokens;
resolvedDefinitions = resolveDefinitions(
(definitions as unknown) as MakeStylesResolvedDefinition<Selectors, Tokens>[],
tokens,
Expand Down Expand Up @@ -89,7 +89,8 @@ export function makeStyles<Selectors, Tokens>(
}

const overridesHash = overridesCx === '' ? '' : overridesCx;
const cxCacheKey = options.renderer.id + matchedIndexes + '' + overridesHash;
const matchedDefinitionsHash = JSON.stringify(matchedDefinitions);
const cxCacheKey = options.renderer.id + matchedIndexes + '' + overridesHash + matchedDefinitionsHash;
const cxCacheElement = cxCache[cxCacheKey];

if (CAN_USE_CSS_VARIABLES && cxCacheElement !== undefined) {
Expand Down
21 changes: 13 additions & 8 deletions packages/make-styles/src/runtime/resolveDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,25 @@ export function resolveDefinitions<Selectors, Tokens>(
const matcher = definition[0];
const styleRule = definition[1];
const resolvedRule = definition[2];
const cachedTokens = definition[3];

const tokensAsJson = JSON.stringify(tokens);

if (CAN_USE_CSS_VARIABLES) {
// we can always use prebuilt styles in this case and static cache in runtime

if (resolvedRule) {
return [matcher, undefined, resolvedRule];
if (resolvedRule && tokensAsJson === cachedTokens) {
return [matcher, undefined, resolvedRule, cachedTokens];
}

// if static cache is not present, eval it and mutate original object
const styles: MakeStyles =
typeof styleRule === 'function' ? (styleRule as MakeStylesStyleFunctionRule<Tokens>)(tokens!!) : styleRule!!;

definitions[i][2] = resolveStyleRules(styles, unstable_cssPriority);
definitions[i][3] = tokensAsJson;

return [matcher, undefined, definition[2]];
return [matcher, undefined, definition[2], definitions[i][3]];
}

// if CSS variables are not supported we have to re-eval only functions, otherwise static cache can be reused
Expand All @@ -74,8 +78,8 @@ export function resolveDefinitions<Selectors, Tokens>(
const path = [tokens, styleRule];
const resolvedStyles = graphGet(graph, path);

if (resolvedStyles) {
return [matcher, undefined, resolvedStyles];
if (resolvedStyles && tokensAsJson === cachedTokens) {
return [matcher, undefined, resolvedStyles, cachedTokens];
}

const resolveStyles1 = resolveStyleRules(
Expand All @@ -84,15 +88,16 @@ export function resolveDefinitions<Selectors, Tokens>(
);
graphSet(graph, path, resolveStyles1);

return [matcher, undefined, resolveStyles1];
return [matcher, undefined, resolveStyles1, tokensAsJson];
}

if (resolvedRule) {
return [matcher, undefined, resolvedRule];
return [matcher, undefined, resolvedRule, cachedTokens];
}

definitions[i][2] = resolveStyleRules(styleRule!!, unstable_cssPriority);
definitions[i][3] = tokensAsJson;

return [matcher, undefined, definition[2]];
return [matcher, undefined, definition[2], definitions[i][3]];
});
}
4 changes: 2 additions & 2 deletions packages/make-styles/src/runtime/resolveStyleRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function resolveStyleRules(
property,
support,
value,
unstable_cssPriority
unstable_cssPriority,
});

const rtl = convertProperty(property, value);
Expand All @@ -60,7 +60,7 @@ export function resolveStyleRules(
property: rtl.key,
support,
value: rtl.value,
unstable_cssPriority
unstable_cssPriority,
});

// There is no sense to store RTL className as it's "r" + regular className
Expand Down
1 change: 1 addition & 0 deletions packages/make-styles/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type MakeStylesResolvedDefinition<Selectors, Tokens> = [
MakeStylesMatcher<Selectors>,
MakeStylesStyleRule<Tokens> | undefined,
Record<string, MakeStylesResolvedRule>,
string,
];

// Renderer types
Expand Down
Loading