Skip to content

Commit

Permalink
Merge branch 'master' into 7682-modal-content-position
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Feb 2, 2021
2 parents 2a97835 + fd3729c commit beb37e2
Show file tree
Hide file tree
Showing 164 changed files with 7,981 additions and 1,449 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/offline-mirror/@babel-preset-react-7.10.4.tgz
Binary file not shown.
Binary file removed .yarn/offline-mirror/@babel-types-7.11.5.tgz
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/**
* Copyright IBM Corp. 2016, 2018
* Copyright IBM Corp. 2021, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
module.exports = require('./dist/react');

module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2018
* Copyright IBM Corp. 2021, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -8,7 +8,7 @@
import React, { useCallback, useState } from 'react';
import PropTypes from 'prop-types';
import { Form } from '@storybook/components';
import { CARBON_TYPE_TOKEN } from '../shared';
import { CARBON_CURRENT_THEME, CARBON_TYPE_TOKEN } from '../shared';

const typeTokenPairings = [
'12-16',
Expand Down Expand Up @@ -36,15 +36,69 @@ const typeTokenDefaults = {
'productive-heading-04': '28-36',
};

/**
* Storybook add-on panel for Carbon type token switcher.
*/
export const CarbonThemePanel = ({ api, active }) => {
const [currentTheme, setCurrentTheme] = useState('white');
const handleChange = useCallback(
(event) => {
const { value } = event.target;
setCurrentTheme(value);
api.getChannel().emit(CARBON_CURRENT_THEME, value);
},
[api]
);
return (
active && (
<Form>
<Form.Field label="Select Carbon theme:">
<Form.Select
name="carbon-theme"
value={currentTheme}
onChange={handleChange}
size="flex">
<option key="white" value="white">
white
</option>
<option key="g10" value="g10">
g10
</option>
<option key="g90" value="g90">
g90
</option>
<option key="g100" value="g100">
g100
</option>
</Form.Select>
</Form.Field>
</Form>
)
);
};

CarbonThemePanel.propTypes = {
/**
* `true` if this Storybook add-on panel is active.
*/
active: PropTypes.bool.isRequired,

/**
* The Storybook API object.
*/
api: PropTypes.shape({
getChannel: PropTypes.func,
}).isRequired,
};

export const CarbonTypePanel = ({ api, active }) => {
const [currentTypeTokens, setCurrentTypeTokens] = useState(typeTokenDefaults);
const handleTokenChange = useCallback(
(event) => {
const { name: tokenName, value: tokenValue } = event.target;
setCurrentTypeTokens({ ...currentTypeTokens, [tokenName]: tokenValue });
setCurrentTypeTokens((currentTypeTokens) => {
return {
...currentTypeTokens,
[tokenName]: tokenValue,
};
});
api.getChannel().emit(CARBON_TYPE_TOKEN, { tokenName, tokenValue });
},
[api]
Expand Down Expand Up @@ -76,15 +130,15 @@ export const CarbonTypePanel = ({ api, active }) => {
};

CarbonTypePanel.propTypes = {
/**
* `true` if this Storybook add-on panel is active.
*/
active: PropTypes.bool.isRequired,

/**
* The Storybook API object.
*/
api: PropTypes.shape({
getChannel: PropTypes.func,
}).isRequired,

/**
* `true` if this Storybook add-on panel is active.
*/
active: PropTypes.bool.isRequired,
};
14 changes: 14 additions & 0 deletions config/storybook-preset-carbon/carbon-theme-addon/src/preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright IBM Corp. 2021, 2021
*
* 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 strict';

module.exports = {
managerEntries(entry = []) {
return [...entry, require.resolve('./register')];
},
};
36 changes: 36 additions & 0 deletions config/storybook-preset-carbon/carbon-theme-addon/src/register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright IBM Corp. 2021, 2021
*
* 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 { addons } from '@storybook/addons';
import { CarbonThemePanel, CarbonTypePanel } from './components/Panel';
import {
CARBON_THEMES_ADDON_ID,
CARBON_THEME_PANEL_ID,
CARBON_TYPE_ADDON_ID,
CARBON_TYPE_PANEL_ID,
} from './shared';

// Disabling because storybook addons doesn't provide proptypes or display names for these panels
/* eslint-disable react/display-name, react/prop-types */
addons.register(CARBON_THEMES_ADDON_ID, (api) => {
addons.addPanel(CARBON_THEME_PANEL_ID, {
title: 'Carbon Theme',
render: ({ active, key }) => (
<CarbonThemePanel api={api} key={key} active={active} />
),
});
});

addons.register(CARBON_TYPE_ADDON_ID, (api) => {
addons.addPanel(CARBON_TYPE_PANEL_ID, {
title: 'Carbon Type',
render: ({ active, key }) => (
<CarbonTypePanel api={api} key={key} active={active} />
),
});
});
13 changes: 13 additions & 0 deletions config/storybook-preset-carbon/carbon-theme-addon/src/shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Copyright IBM Corp. 2021, 2021
*
* 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 const CARBON_THEMES_ADDON_ID = 'carbon-theme';
export const CARBON_CURRENT_THEME = `${CARBON_THEMES_ADDON_ID}/current`;
export const CARBON_THEME_PANEL_ID = `${CARBON_THEMES_ADDON_ID}/panel`;
export const CARBON_TYPE_ADDON_ID = 'carbon-type';
export const CARBON_TYPE_TOKEN = `${CARBON_TYPE_ADDON_ID}/type`;
export const CARBON_TYPE_PANEL_ID = `${CARBON_TYPE_ADDON_ID}/panel`;
6 changes: 3 additions & 3 deletions config/storybook-preset-carbon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ module.exports = {
'@storybook/addon-storysource',
'@storybook/addon-knobs',
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-docs',
'@storybook/addon-notes/register',
'storybook-readme/register',

// Phase 3: port over custom panels/add-ons
'@storybook/addon-links',
CARBON_REACT_STORYBOOK_USE_CUSTOM_PROPERTIES === 'true' &&
require.resolve('./dist/preset.js'),
],

webpack(config) {
Expand Down
19 changes: 16 additions & 3 deletions config/storybook-preset-carbon/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "storybook-preset-carbon",
"private": true,
"version": "0.1.0",
"version": "0.2.0-rc.0",
"license": "Apache-2.0",
"main": "index.js",
"repository": {
Expand All @@ -17,10 +17,18 @@
"components",
"react"
],
"scripts": {
"build": "babel ./carbon-theme-addon/src --out-dir ./dist",
"clean": "rimraf ./dist"
},
"peerDependencies": {
"@storybook/react": "^5.3.19"
"@storybook/react": "^5.3.19",
"react": "^16.8.6 || ^17.0.1",
"react-dom": "^16.8.6 || ^17.0.1"
},
"dependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@storybook/addon-actions": "^5.3.19",
"@storybook/addon-docs": "^5.3.19",
"@storybook/addon-knobs": "^5.3.19",
Expand All @@ -29,9 +37,14 @@
"@storybook/addon-storysource": "^5.3.19",
"@storybook/addons": "^5.3.19",
"@storybook/source-loader": "^5.3.19",
"react-is": "^16.8.6",
"storybook-readme": "^5.0.8"
},
"devDependencies": {
"@storybook/react": "^5.3.19"
"@storybook/react": "^5.3.19",
"babel-loader": "^8.2.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"webpack": "^4.41.5"
}
}
24 changes: 24 additions & 0 deletions docs/migration/11.x-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# @carbon/type

**Note: everything in this file is a work-in-progress and will be changed.**

## Changes

| Filename | v10 | v11 |
| ------------------------ | --------------------------------- | --------------------------------- |
| `scss/_scale.scss` | `@function carbon--get-type-size` | Removed, use `type-scale` instead |
| | `$carbon--type-scale` | `$type-scale` |
| | `@function carbon--type-scale` | `@function type-scale` |
| | `@mixin carbon--type-scale` | `@mixin type-scale` |
| | `@mixin carbon--font-size` | `@mixin font-size` |
| `scss/_font-family.scss` | `$carbon--font-families` | `$font-families` |
| | `@function carbon--font-family` | `font-family` |
| | `@mixin carbon--font-family` | `font-family` |
| | `$carbon--font-weights` | `$font-weights` |
| | `@function carbon--font-weight` | `font-weight` |
| | `@mixin carbon--font-weight` | `font-weight` |
| `scss/_prefix.scss` | | No Changes |
| `scss/_styles.scss` | `@mixin carbon--type-style` | `@mixin type-style` |
| `scss/_reset.scss` | `@mixin carbon--default-type` | `@mixin default-type` |
| | `@mixin carbon--type-reset` | `@mixin type-reset` |
| `scss/_classes.scss` | `@mixin carbon--type-classes` | `@mixin type-classes` |
Loading

0 comments on commit beb37e2

Please sign in to comment.