Skip to content
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

fix: fix carbonization #1253

Merged
merged 2 commits into from
Sep 12, 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
6 changes: 3 additions & 3 deletions e2e/carbon/carbon.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
@use '@carbon/styles' as * with (
$font-path: 'https://fonts.camunda.io'
$font-path: '@ibm/plex'
);
@use '@carbon/styles/scss/themes';
@use '@carbon/styles/scss/theme';

@import '@bpmn-io/form-js-carbon-styles/src/carbon-styles';

.cds--g10 {
[data-carbon-theme='g10'] {
@include theme.theme(themes.$g10);
}

.cds--g100 {
[data-carbon-theme='g100'] {
@include theme.theme(themes.$g100);
}
4 changes: 2 additions & 2 deletions e2e/carbon/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="en" data-carbon-theme="g100">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Expand All @@ -20,7 +20,7 @@
}
</style>
</head>
<body class="cds--g100">
<body>
<div id="container" role="main"></div>
<script type="module" src="index.js"></script>
</body>
Expand Down
6 changes: 3 additions & 3 deletions e2e/carbon/theme.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@use '@carbon/styles' as * with (
$font-path: 'https://fonts.camunda.io'
$font-path: '@ibm/plex'
);
@use '@carbon/styles/scss/themes';
@use '@carbon/styles/scss/theme';

.cds--g10 {
[data-carbon-theme='g10'] {
@include theme.theme(themes.$g10);
}

.cds--g100 {
[data-carbon-theme='g100'] {
@include theme.theme(themes.$g100);
}
2 changes: 1 addition & 1 deletion e2e/theming/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
</style>
</head>
<body class="cds--g10">
<body>
<div id="container" role="main"></div>
<script type="module" src="index.js"></script>
</body>
Expand Down
6 changes: 3 additions & 3 deletions e2e/theming/theme.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@use '@carbon/styles' as * with (
$font-path: 'https://fonts.camunda.io'
$font-path: '@ibm/plex'
);
@use '@carbon/styles/scss/themes';
@use '@carbon/styles/scss/theme';

.cds--g10 {
[data-carbon-theme='g10'] {
@include theme.theme(themes.$g10);
}

.cds--g100 {
[data-carbon-theme='g100'] {
@include theme.theme(themes.$g100);
}
8 changes: 2 additions & 6 deletions e2e/visual/theming.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ test('theming - viewer', async ({ page, makeAxeBuilder }) => {
});

await page.evaluate(() => {
const container = document.querySelector('body');
container.classList.remove('cds--g10');
container.classList.add('cds--g100');
document.documentElement.setAttribute('data-carbon-theme', 'g100');
});

// then
Expand Down Expand Up @@ -63,9 +61,7 @@ test('theming - editor', async ({ page, makeAxeBuilder }) => {
});

await page.evaluate(() => {
const container = document.querySelector('body');
container.classList.remove('cds--g10');
container.classList.add('cds--g100');
document.documentElement.setAttribute('data-carbon-theme', 'g100');
});

// then
Expand Down
6 changes: 3 additions & 3 deletions packages/form-js-carbon-styles/src/carbon-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

// Themed icons /////////////

.cds--g10 {
[data-carbon-theme='g10'] {
.fjs-container {
.fjs-form-field-number .fjs-input-group {
.fjs-number-arrow-container {
Expand Down Expand Up @@ -114,7 +114,7 @@
}
}

.cds--g100 {
[data-carbon-theme='g100'] {
.fjs-container {
.fjs-form-field-number .fjs-input-group {
.fjs-number-arrow-container {
Expand Down Expand Up @@ -1269,7 +1269,7 @@
}

.fjs-table-th {
color: var(--cds-color-primary);
color: var(--cds-text-primary);
font-size: var(--cds-heading-compact-01-font-size);
font-weight: var(--cds-heading-compact-01-font-weight);
line-height: var(--cds-heading-compact-01-line-height);
Expand Down
15 changes: 9 additions & 6 deletions packages/form-js-carbon-styles/test/spec/carbon-styles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ describe('Carbon styles', function () {

beforeEach(function () {
container = document.createElement('div');
container.classList.add('cds--g100');

document.body.appendChild(container);
document.documentElement.setAttribute('data-carbon-theme', 'g100');
});

!singleStart &&
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('Carbon styles', function () {
});

toggle.addEventListener('click', () => {
toggleTheme(container);
toggleTheme();
theme = theme === 'dark' ? 'light' : 'dark';
createFormView(
{
Expand Down Expand Up @@ -191,7 +191,7 @@ describe('Carbon styles', function () {
});

toggle.addEventListener('click', () => {
toggleTheme(container);
toggleTheme();
theme = theme === 'dark' ? 'light' : 'dark';
createFormView(
{
Expand Down Expand Up @@ -284,7 +284,10 @@ function WithTheme(props) {
return <ThemeProvider theme={theme}>{props.children}</ThemeProvider>;
}

function toggleTheme(node) {
node.classList.toggle('cds--g100');
node.classList.toggle('cds--g10');
function toggleTheme() {
if (document.documentElement.dataset.carbonTheme === 'cds--g100') {
document.documentElement.setAttribute('data-carbon-theme', 'g10');
} else {
document.documentElement.setAttribute('data-carbon-theme', 'g100');
}
}
6 changes: 3 additions & 3 deletions packages/form-js-carbon-styles/test/spec/theme.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@use '@carbon/react' as * with (
$font-path: 'https://fonts.camunda.io'
$font-path: '@ibm/plex'
);

@use '@carbon/react/scss/themes';
@use '@carbon/react/scss/theme';

.cds--g10 {
[data-carbon-theme='g10'] {
@include theme.theme(themes.$g10);
}

.cds--g100 {
[data-carbon-theme='g100'] {
@include theme.theme(themes.$g100);
}
4 changes: 2 additions & 2 deletions packages/form-js-editor/test/spec/FormEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('FormEditor', function () {

(singleStartTheme ? it.only : it)('should render theme', async function () {
// given
container.classList.add('cds--g100');
document.documentElement.setAttribute('data-carbon-theme', 'g100');
insertTheme();

// when
Expand All @@ -104,7 +104,7 @@ describe('FormEditor', function () {

(singleStartNoTheme ? it.only : it)('should render with no theme', async function () {
// given
container.classList.add('cds--g10');
document.documentElement.setAttribute('data-carbon-theme', 'g10');
container.style.backgroundColor = 'white';
insertTheme();

Expand Down
4 changes: 2 additions & 2 deletions packages/form-js-viewer/test/spec/Form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('Form', function () {

(singleStartTheme ? it.only : it)('should render theme', async function () {
// given
container.classList.add('cds--g100');
document.documentElement.setAttribute('data-carbon-theme', 'g100');
insertTheme();

const data = {
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('Form', function () {

(singleStartNoTheme ? it.only : it)('should render with no theme', async function () {
// given
container.classList.add('cds--g10');
document.documentElement.setAttribute('data-carbon-theme', 'g100');
container.style.backgroundColor = 'white';
insertTheme();

Expand Down
Loading