Skip to content

Commit

Permalink
fix: Ensure SCSS for all components and stories sets required carbon …
Browse files Browse the repository at this point in the history
…and project settings (#1166)

* fix: consolidate carbon and project settings for consistency

* chore: remove unnecessary carbon imports

* chore: add styles tests

* chore: add type styles to project settings
  • Loading branch information
dcwarwick authored Aug 18, 2021
1 parent 1e19e3c commit 5c77105
Show file tree
Hide file tree
Showing 57 changed files with 51 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';
@import '../../global/styles/mixins';

// Other Carbon settings.
// TODO: add as required
// TODO: @import 'carbon-components/scss/globals/grid/grid'; if needed

// DISPLAY_NAME uses the following Carbon components:
// TODO: @import(s) of Carbon component styles used by DISPLAY_NAME
Expand Down
23 changes: 23 additions & 0 deletions packages/cloud-cognitive/src/__tests__/styles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,27 @@ describe(name, () => {
}).css.toString()
).toMatchSnapshot();
});

// This test will fail if any generated CSS changes.
it.skip("doesn't change any of the generated CSS", () => {
expect(
renderSync({
file: resolve(__dirname, '../index.scss'),
includePaths: [resolve(__dirname, '../../../../node_modules')],
outputStyle: 'expanded',
}).css.toString()
).toMatchSnapshot();
});

// This test will fail if the project settings generates any CSS, as this
// file should be including definitions and variables only.
it("doesn't generate any CSS from the project settings", () => {
expect(
renderSync({
file: resolve(__dirname, '../global/styles/_project-settings.scss'),
includePaths: [resolve(__dirname, '../../../../node_modules')],
outputStyle: 'expanded',
}).css.toString()
).toHaveLength(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// APIKeyModal uses the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// LICENSE file in the root directory of this source tree.
//

@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

$block-class: #{$pkg-prefix}--apikey-modal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// Other Carbon settings.
@import '@carbon/themes/scss/themes';
@import 'carbon-components/scss/globals/scss/vars';

// AboutModal uses the following Carbon components:
// ComposedModal, ModalHeader, ModalFooter, ModalBody, Tabs, Tab
@import 'carbon-components/scss/components/modal/modal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// LICENSE file in the root directory of this source tree.
//

@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

.about-modal-stories--tech-logo {
width: 2.25rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// Other Carbon settings.
@import '../../global/styles/mixins';

// ActionBar uses the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// LICENSE file in the root directory of this source tree.
//

@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

@import 'carbon-components/scss/components/button/button';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// LICENSE file in the root directory of this source tree.
//

@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

$block-class: #{$pkg-prefix}--action-set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// Other Carbon settings.
@import '../../global/styles/mixins';

// BreadcrumbWithOverflow uses the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// TODO: @import(s) of Carbon settings and component styles and other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
// LICENSE file in the root directory of this source tree.
//
// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings'; // goes before index as it affects how carbon is used.
@import '../../global/styles/project-settings';

// Other Carbon settings.
@import '../../global/styles/mixins';

// ButtonSetWithOverflow uses the following Carbon components:
Expand Down
2 changes: 0 additions & 2 deletions packages/cloud-cognitive/src/components/Card/_card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// Card uses the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
// LICENSE file in the root directory of this source tree.
//

@import '@carbon/import-once/scss/import-once';

@import '@carbon/layout/scss/convert';
@import '@carbon/layout/scss/mini-unit';

@import '@carbon/themes/scss/tokens';

@import 'carbon-components/scss/globals/scss/helper-mixins';
@import 'carbon-components/scss/globals/scss/vars';
@import '../../global/styles/project-settings';

@import 'carbon-components/scss/components/button/button';
@import 'carbon-components/scss/components/overflow-menu/overflow-menu';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

.#{$pkg-prefix}-context-header {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// Other Carbon settings.
Expand All @@ -21,10 +19,10 @@
@import 'carbon-components/scss/components/toggle/toggle';
@import 'carbon-components/scss/components/modal/modal';
@import 'carbon-components/scss/components/button/button';
@import '../CreateInfluencer/index';

// CreateFullPage uses the following Cloud & Cognitive components:
// ActionSet
// ActionSet, CreateInfluencer
@import '../CreateInfluencer/index';
@import '../ActionSet/action-set';

// Define all component styles in a mixin which is then exported using
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

@import 'carbon-components/scss/components/ui-shell/ui-shell';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
// LICENSE file in the root directory of this source tree.
//

@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

@import 'carbon-components/scss/components/progress-indicator/progress-indicator';

@mixin create-influencer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
//

// Standard imports.
@import '@carbon/themes/scss/themes';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// Other Carbon settings.
@import 'carbon-components/scss/globals/scss/_vars.scss';

// CreateModal uses the following Carbon components:
// ComposedModal, ModalHeader, ModalFooter, ModalBody, Form, Button
@import 'carbon-components/scss/components/modal/modal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// Other Carbon settings.
@import '../SidePanel/side-panel-variables';

// CreateSidePanel uses the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// LICENSE file in the root directory of this source tree.
//

@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

$block-class: #{$pkg-prefix}--create-side-panel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// CreateTearsheet uses the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// LICENSE file in the root directory of this source tree.
//

@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

$preview-block-class: #{$pkg-prefix}--tearsheet-create-multi-step;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// CreateTearsheetNarrow uses the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

@import './index';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// Uncomment next line (which must appear last) to test in storybook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// Empty states use the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// ExampleComponent uses the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

// Standard imports.
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// ExportModal uses the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// ExpressiveCard uses the following Cloud & Cognitive components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// HTTP errors use the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

// Standard imports.
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// ImportModal uses the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// Other Carbon settings.
@import '@carbon/themes/scss/themes';
@import 'carbon-components/scss/globals/scss/_vars.scss';

$loading-bar__height: 8px;
$loading-bar__small-height: 4px;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// LICENSE file in the root directory of this source tree.
//

@import './index';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// add any additional styles used by LoadingBar.stories.js
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// ModifiedTabs uses the following Carbon components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@
//

// Standard imports.
@import '@carbon/import-once/scss/import-once';
@import '../../global/styles/carbon-settings';
@import '../../global/styles/project-settings';

// Other Carbon settings.
@import '@carbon/themes/scss/themes';
@import '@carbon/colors/scss/colors';
@import '@carbon/motion/scss/motion';

// NotificationsPanel uses the following Carbon components:
// Button, Link, Toggle
@import 'carbon-components/scss/components/button/button';
Expand Down
Loading

0 comments on commit 5c77105

Please sign in to comment.