Skip to content

Commit 2fd1126

Browse files
committed
feat(samples): move data-theme to body
1 parent b06a22c commit 2fd1126

3 files changed

Lines changed: 4 additions & 8 deletions

File tree

samples/grids/grid-lite/styling-config-themes/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="shortcut icon" href="https://dl.infragistics.com/x/img/browsers/react.png" >
66
<link rel="stylesheet" href="https://dl.infragistics.com/x/css/samples/shared.v8.css" />
77
</head>
8-
<body>
8+
<body data-theme="bootstrap-light">
99
<div id="root"></div>
1010
<script type="module" src="/src/index.tsx"></script>
1111
</body>

samples/grids/grid-lite/styling-config-themes/src/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $themes: (
3333

3434
// Generate theme classes
3535
@each $name, $config in $themes {
36-
.grid-lite-wrapper[data-theme="#{$name}"] {
36+
body[data-theme="#{$name}"] .grid-lite-wrapper {
3737
@include palette(list.nth($config, 1));
3838
@include typography(list.nth($config, 2), list.nth($config, 3));
3939
}

samples/grids/grid-lite/styling-config-themes/src/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ defineComponents(IgcRatingComponent, IgcSelectComponent);
3030
export default class Sample extends React.Component<any, any> {
3131
private dataService: GridLiteDataService;
3232
private gridRef: React.RefObject<any>;
33-
private wrapperRef: React.RefObject<HTMLDivElement>;
3433
private selectRef: React.RefObject<any>;
3534

3635
constructor(props: any) {
3736
super(props);
3837
this.dataService = new GridLiteDataService();
3938
this.gridRef = React.createRef();
40-
this.wrapperRef = React.createRef();
4139
this.selectRef = React.createRef();
4240
this.state = {
4341
currentTheme: 'bootstrap-light'
@@ -61,9 +59,7 @@ export default class Sample extends React.Component<any, any> {
6159

6260
private changeTheme = (theme: string) => {
6361
this.setState({ currentTheme: theme });
64-
if (this.wrapperRef.current) {
65-
this.wrapperRef.current.setAttribute('data-theme', theme);
66-
}
62+
document.body.setAttribute('data-theme', theme);
6763
}
6864

6965
public render(): JSX.Element {
@@ -83,7 +79,7 @@ export default class Sample extends React.Component<any, any> {
8379
</igc-select>
8480
</div>
8581

86-
<div className="grid-lite-wrapper" ref={this.wrapperRef}>
82+
<div className="grid-lite-wrapper">
8783
<igc-grid-lite ref={this.gridRef} id="grid-lite">
8884
<igc-grid-lite-column field="name" header="Product" sortable filterable></igc-grid-lite-column>
8985
<igc-grid-lite-column field="price" header="Price" sortable filterable data-type="number"></igc-grid-lite-column>

0 commit comments

Comments
 (0)