Skip to content

Commit f0c98a7

Browse files
authored
feat(TDOPS-5212): Components - Add a theme props to Layout component (#4892)
1 parent 55c666d commit f0c98a7

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

.changeset/wicked-points-cough.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@talend/react-components': minor
3+
---
4+
5+
Components - Layout can now be given a theme directly from props by parent app

packages/components/src/Layout/Layout.component.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import OneColumn from './OneColumn';
77
import TwoColumns from './TwoColumns';
88
import SkipLinks from './SkipLinks';
99

10-
import theme from './Layout.module.scss';
10+
import style from './Layout.module.scss';
1111

1212
const DISPLAY_MODES = {
1313
ONE_COLUMN: 'OneColumn',
@@ -42,13 +42,14 @@ function Layout({
4242
drawers,
4343
tabs,
4444
hasTheme,
45+
theme,
4546
children,
4647
getComponent,
4748
...rest
4849
}) {
49-
const appCSS = classnames('tc-layout', theme.layout, hasTheme && TALEND_T7_THEME_CLASSNAME);
50-
const headerCSS = classnames('tc-layout-header', theme.header);
51-
const footerCSS = classnames('tc-layout-footer', theme.footer);
50+
const appCSS = classnames('tc-layout', style.layout, hasTheme && TALEND_T7_THEME_CLASSNAME);
51+
const headerCSS = classnames('tc-layout-header', style.header);
52+
const footerCSS = classnames('tc-layout-footer', style.footer);
5253
let Component;
5354
let skipLinkNavigationId;
5455
switch (mode) {
@@ -70,9 +71,9 @@ function Layout({
7071
const safeFooter = Inject.getReactElement(getComponent, footer);
7172

7273
return (
73-
<ThemeProvider>
74+
<ThemeProvider theme={theme}>
7475
<div id={id} className={appCSS}>
75-
<div className={theme['skip-links']}>
76+
<div className={style['skip-links']}>
7677
<SkipLinks navigationId={skipLinkNavigationId} mainId="#tc-layout-main" />
7778
</div>
7879
{safeHeader && (
@@ -117,6 +118,7 @@ Layout.propTypes = {
117118
drawers: PropTypes.arrayOf(PropTypes.element),
118119
tabs: PropTypes.shape(TabBar.propTypes),
119120
hasTheme: PropTypes.bool,
121+
theme: PropTypes.string,
120122
children: PropTypes.node,
121123
getComponent: PropTypes.func,
122124
};

0 commit comments

Comments
 (0)