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

feat(Tag): add Tag to @carbon/styles #9131

Merged
merged 14 commits into from
Jul 23, 2021
Merged
9 changes: 5 additions & 4 deletions packages/carbon-react/.storybook/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@ $feature-flags: (

@use '../index.scss' as styles;
@use '../scss/components/button';
@use '../scss/components/tag';

// For now, including all weights for testing
@include arabic.all;
@include sans.all;
@include mono.all;

:root {
@include styles.theme(styles.$white, button.$white);
@include styles.theme(styles.$white, button.$white, tag.$white);
}

[data-carbon-theme='g10'] {
@include styles.theme(styles.$g10, button.$g10);
@include styles.theme(styles.$g10, button.$g10, tag.$g10);
}

[data-carbon-theme='g90'] {
@include styles.theme(styles.$g90, button.$g90);
@include styles.theme(styles.$g90, button.$g90, tag.$g90);
}

[data-carbon-theme='g100'] {
@include styles.theme(styles.$g100, button.$g100);
@include styles.theme(styles.$g100, button.$g100, tag.$g100);
}

html[lang='en'] body {
Expand Down
8 changes: 8 additions & 0 deletions packages/carbon-react/scss/components/_tag.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// Copyright IBM Corp. 2018, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

@forward '@carbon/styles/scss/components/tag';
47 changes: 47 additions & 0 deletions packages/carbon-react/src/components/Tag/Tag.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* 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 React from 'react';
import { Tag } from 'carbon-components-react';

export default {
title: 'Components/Tag',
parameters: {
component: Tag,
},
};

export const Default = () => {
return (
<>
<Tag className="some-class" type="red" size="sm" title="Clear Filter">
{'Tag content'}
</Tag>
<Tag className="some-class" type="magenta" size="sm" title="Clear Filter">
{'Tag content'}
</Tag>
<Tag className="some-class" type="purple" size="sm" title="Clear Filter">
{'Tag content'}
</Tag>
<Tag className="some-class" type="blue" size="sm" title="Clear Filter">
{'Tag content'}
</Tag>
<Tag className="some-class" type="cyan" size="sm" title="Clear Filter">
{'Tag content'}
</Tag>
<Tag className="some-class" type="teal" size="sm" title="Clear Filter">
{'Tag content'}
</Tag>
<Tag className="some-class" type="green" size="sm" title="Clear Filter">
{'Tag content'}
</Tag>
<Tag className="some-class" type="gray" size="sm" title="Clear Filter">
{'Tag content'}
</Tag>
</>
);
};
8 changes: 8 additions & 0 deletions packages/carbon-react/src/components/Tag/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

export { Tag } from 'carbon-components-react';
25 changes: 25 additions & 0 deletions packages/styles/scss/components/__tests__/tag-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright IBM Corp. 2018, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*
* @jest-environment node
*/

'use strict';

const { SassRenderer } = require('@carbon/test-utils/scss');

const { render } = SassRenderer.create(__dirname);

describe('scss/components/tag', () => {
test('Public API', async () => {
const { unwrap } = await render(`
@use 'sass:meta';
@use '../tag/tag';
$_: get('mixin', meta.mixin-exists('tag', 'tag'));
`);
expect(unwrap('mixin')).toBe(true);
});
});
1 change: 1 addition & 0 deletions packages/styles/scss/components/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@use 'data-table/expandable';
@use 'data-table/skeleton';
@use 'data-table/sort';
@use 'tag';
@use "slider";
@use 'text-area';
@use 'text-input';
Expand Down
12 changes: 12 additions & 0 deletions packages/styles/scss/components/tag/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Copyright IBM Corp. 2018, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

@forward 'tag';
@forward 'tokens';
@use 'tag';

@include tag.tag;
21 changes: 21 additions & 0 deletions packages/styles/scss/components/tag/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//
@use '../../config' as *;

/// @access private
/// @group tag
@mixin tag-theme($bg-color, $text-color, $filter-hover-color: $bg-color) {
background-color: $bg-color;
color: $text-color;

&.#{$prefix}--tag--interactive,
.#{$prefix}--tag__close-icon {
&:hover {
background-color: $filter-hover-color;
}
}
}
Loading