Skip to content

Commit

Permalink
feat: add dynamic styles to benchmarks fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Samantha-Zhan committed Dec 11, 2024
1 parent 95feb9f commit 7ffc04b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
4 changes: 3 additions & 1 deletion apps/rollup-example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

import stylex from '@stylexjs/stylex';
import { lotsOfStyles } from './lotsOfStyles';
import { lotsOfStylesDynamic } from './lotsOfStylesDynamic.js';

const styles = lotsOfStyles.map((defs) => Object.values(defs));
const dynamicStyles = lotsOfStylesDynamic.map((defs) => Object.values(defs));

export default function App() {
return stylex.props(styles);
return stylex.props(styles, dynamicStyles);
}
44 changes: 44 additions & 0 deletions apps/rollup-example/lotsOfStylesDynamic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/

'use strict';

import * as stylex from '@stylexjs/stylex';

export const lotsOfStylesDynamic = [
stylex.create({
// Dynamic styles
dynamicHeight: (height) => ({
height,
}),
dynamicPadding: (paddingTop, paddingBottom) => ({
paddingTop,
paddingBottom,
}),
dynamicTextColor: (textColor) => ({
color: textColor,
}),
}),
stylex.create({
// Mixed dynamic and regular styles
dynamicHeightWithStatic: (height) => ({
height,
backgroundColor: 'var(--background-color)',
}),
dynamicPaddingWithStatic: (paddingTop, paddingBottom) => ({
paddingTop,
paddingBottom,
margin: '8px',
}),
dynamicTextColorWithStatic: (textColor) => ({
color: textColor,
fontSize: '16px',
}),
}),
];
3 changes: 2 additions & 1 deletion typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
extend-exclude = [
"*.snap",
"apps/rollup-example/lotsOfStyles.js",
"apps/rollup-example/lotsOfStylesDynamic.js",
"flow-typed/*",
]

[default.extend-words]
# Ignore false-positives
stylex = "stylex"
stylex = "stylex"

0 comments on commit 7ffc04b

Please sign in to comment.