Skip to content

Commit 72b6007

Browse files
authored
[Spaces] SASS modularization (#65921) (#66312)
* Removing Spaces legacy styles import in favor of direct plugin import * Modularizing the `/management` components * Further modularization within copy_saved_objects_to_space * Add styling section to CONTRIBUTING * SASS lint and snaps * Adding link to EUI SASS
1 parent e2cffce commit 72b6007

27 files changed

+76
-65
lines changed

.sass-lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ files:
1111
- 'x-pack/plugins/cross_cluster_replication/**/*.s+(a|c)ss'
1212
- 'x-pack/legacy/plugins/maps/**/*.s+(a|c)ss'
1313
- 'x-pack/plugins/maps/**/*.s+(a|c)ss'
14+
- 'x-pack/plugins/spaces/**/*.s+(a|c)ss'
1415
ignore:
1516
- 'x-pack/plugins/canvas/shareable_runtime/**/*.s+(a|c)ss'
1617
rules:

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,34 @@ extract them to a `JSON` file or integrate translations back to Kibana. To know
403403
We cannot support accepting contributions to the translations from any source other than the translators we have engaged to do the work.
404404
We are still to develop a proper process to accept any contributed translations. We certainly appreciate that people care enough about the localization effort to want to help improve the quality. We aim to build out a more comprehensive localization process for the future and will notify you once contributions can be supported, but for the time being, we are not able to incorporate suggestions.
405405

406+
### Syling with SASS
407+
408+
When writing a new component, create a sibling SASS file of the same name and import directly into the JS/TS component file. Doing so ensures the styles are never separated or lost on import and allows for better modularization (smaller individual plugin asset footprint).
409+
410+
Any JavaScript (or TypeScript) file that imports SASS (.scss) files will automatically build with the [EUI](https://elastic.github.io/eui/#/guidelines/sass) & Kibana invisibles (SASS variables, mixins, functions) from the [`styling_constants.scss` file](https://github.com/elastic/kibana/blob/master/src/legacy/ui/public/styles/_styling_constants.scss). However, any Legacy (file path includes `/legacy`) files will not.
411+
412+
**Example:**
413+
414+
```tsx
415+
// component.tsx
416+
417+
import './component.scss';
418+
419+
export const Component = () => {
420+
return (
421+
<div className="plgComponent" />
422+
);
423+
}
424+
```
425+
426+
```scss
427+
// component.scss
428+
429+
.plgComponent { ... }
430+
```
431+
432+
Do not use the underscore `_` SASS file naming pattern when importing directly into a javascript file.
433+
406434
### Testing and Building
407435

408436
To ensure that your changes will not break other functionality, please run the test suite and build process before submitting your Pull Request.

x-pack/legacy/plugins/spaces/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const spaces = (kibana: Record<string, any>) =>
3030
require: ['kibana', 'elasticsearch', 'xpack_main'],
3131

3232
uiExports: {
33-
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
3433
managementSections: [],
3534
apps: [],
3635
hacks: ['plugins/spaces/legacy'],

x-pack/legacy/plugins/spaces/public/index.scss

Lines changed: 0 additions & 4 deletions
This file was deleted.

x-pack/plugins/spaces/public/copy_saved_objects_to_space/_index.scss

Lines changed: 0 additions & 1 deletion
This file was deleted.

x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/_copy_to_space.scss

Lines changed: 0 additions & 33 deletions
This file was deleted.

x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/_index.scss

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// make icon occupy the same space as an EuiSwitch
2+
// icon is size m, which is the native $euiSize value
3+
// see @elastic/eui/src/components/icon/_variables.scss
4+
.spcCopyToSpaceIncludeRelated .euiIcon {
5+
margin-right: $euiSwitchWidth - $euiSize;
6+
}
7+
8+
.spcCopyToSpaceIncludeRelated__label {
9+
font-size: $euiFontSizeS;
10+
}

x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_form.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import './copy_to_space_form.scss';
78
import React from 'react';
89
import {
910
EuiSwitch,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.spcCopyToSpace__spacesList {
2+
margin-top: $euiSizeXS;
3+
}

0 commit comments

Comments
 (0)