Skip to content

Commit

Permalink
Merge branch 'main' into chore/update-test-deps-july-2021
Browse files Browse the repository at this point in the history
  • Loading branch information
sstrubberg authored Aug 2, 2021
2 parents 8e4090b + f33d65c commit f71c763
Show file tree
Hide file tree
Showing 15 changed files with 592 additions and 143 deletions.
61 changes: 44 additions & 17 deletions packages/carbon-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,30 @@ instead:
yarn add @carbon/react
```

## Usage
This package requires [Dart Sass](http://npmjs.com/package/sass) in order to
compile styles.

If you're new to Sass, or are wondering how to configure Sass for your project,
we recommend checking out the following resources and links:

- [Sass Basics](https://sass-lang.com/guide)
- [Webpack with Sass](https://webpack.js.org/loaders/sass-loader/)
- [Next.js with Sass](https://nextjs.org/docs/basic-features/built-in-css-support#sass-support)
- [Create React App with Sass](https://create-react-app.dev/docs/adding-a-sass-stylesheet/)
- [Parcel with Sass](https://v2.parceljs.org/languages/sass/)
- [Vite with Sass](https://vitejs.dev/guide/features.html#css-pre-processors)
- [Snowpack with Sass](https://www.snowpack.dev/guides/sass/)

**Note: this package is unstable and will change before it's 1.0 release**
Once you get Sass up and running in your project, configure Sass to include
`node_modules` in its `includePaths` option. For more information, checkout the
[configuration](../styles/docs/sass.md#configuration) section in our Sass docs.

## Usage

You can use the `@carbon/react` to bring in components, icons, and styles from
the Carbon Design System.
The `@carbon/react` package provides components and icons for the Carbon Design
System.

To include a component, you can import it:
To use a component, you can import it directly from the package:

```jsx
import { Button } from '@carbon/react';
Expand All @@ -35,8 +51,25 @@ function MyComponent() {
}
```

To include an icon, use the `@carbon/react/icons` entrypoint and import it the
same way you would import a component:
To include the styles for a specific component, you can either import all the
styles from the project or include the styles for a specific component:

```scss
// Bring in all the styles for Carbon
@use '@carbon/react';

// Preferred: bring in the styles for one component
@use '@carbon/react/scss/components/button';
```

For a full list of components available, checkout our
[Storybook](https://carbon-react-next.netlify.app/).

### Icons

The `@carbon/react` package also provides icon components that you can include
in your project. You can import these icon components from the
`@carbon/react/icons` entrypoint:

```jsx
import { Add } from '@carbon/react/icons';
Expand All @@ -46,21 +79,15 @@ function MyComponent() {
}
```

For styles, you can bring them in using Sass Modules:

```jsx
@use '@carbon/react';
```

Note: you will need to configure Sass in order to correctly find modules in your
`node_modules`. Follow [this guide](./docs/sass.md#configuration) to make sure
your project is setup correctly.
For a full list of icons available, checkout our
[website](https://www.carbondesignsystem.com/guidelines/icons/library/).

## 📖 API Documentation

If you're looking for `@carbon/react` API documentation, check out:

- [Sass](./docs/sass.md)
- [Storybook](https://carbon-react-next.netlify.app/)
- [Icon Library](https://www.carbondesignsystem.com/guidelines/icons/library/).

## 🙌 Contributing

Expand Down
109 changes: 0 additions & 109 deletions packages/carbon-react/docs/sass.md

This file was deleted.

9 changes: 5 additions & 4 deletions packages/carbon-react/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "@carbon/react",
"private": true,
"description": "React components for the Carbon Design System",
"version": "0.8.0",
"version": "0.1.0",
"license": "Apache-2.0",
"main": "lib/index.js",
"module": "es/index.js",
Expand All @@ -28,6 +27,9 @@
"components",
"react"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "yarn clean && node tasks/build.js",
"clean": "rimraf es lib",
Expand All @@ -42,7 +44,7 @@
"dependencies": {
"@carbon/feature-flags": "^0.5.0",
"@carbon/icons-react": "^10.36.0",
"@carbon/styles": "^0.11.0",
"@carbon/styles": "^0.1.0",
"@carbon/telemetry": "0.0.0-alpha.6",
"carbon-components-react": "^7.40.0"
},
Expand All @@ -54,7 +56,6 @@
"@babel/plugin-transform-react-constant-elements": "^7.14.5",
"@babel/preset-env": "^7.14.7",
"@babel/preset-react": "^7.14.5",
"@carbon/styles": "^0.11.0-rc.0",
"@carbon/themes": "^10.39.0",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^18.0.0",
Expand Down
98 changes: 98 additions & 0 deletions packages/carbon-react/src/components/Popover/Popover.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* 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 './story.scss';
import React from 'react';
import { Popover, PopoverContent } from '../Popover';

export default {
title: 'Components/Popover',
parameters: {
component: Popover,
subcomponents: {
PopoverContent,
},
},
};

export const Default = () => {
function PopoverDemo() {
const [align, setAlign] = React.useState('top');
const [open, setOpen] = React.useState(true);
const choices = [
'top',
'top-left',
'top-right',

'bottom',
'bottom-left',
'bottom-right',

'left',
'left-bottom',
'left-top',

'right',
'right-bottom',
'right-top',
];

return (
<>
<section>
<h2>Caret Position</h2>
<div
style={{
display: 'grid',
gridTemplateColumns: 'repeat(3, auto)',
gridGap: 8,
}}>
{choices.map((choice) => {
return (
<label key={choice}>
<input
type="radio"
name="align"
value={choice}
checked={choice === align}
onChange={() => {
setAlign(choice);
}}
/>
{choice}
</label>
);
})}
</div>
</section>
<section>
<h2>Popover Visibility</h2>
<div>
<label>
<input
type="checkbox"
value={open}
checked={open}
onChange={() => {
setOpen(!open);
}}
/>
Open
</label>
</div>
</section>
<div style={{ marginTop: '2rem' }}>
<Popover open={open} align={align} relative>
<PopoverContent className="p-3">Hello</PopoverContent>
</Popover>
</div>
</>
);
}

return <PopoverDemo />;
};
59 changes: 59 additions & 0 deletions packages/carbon-react/src/components/Popover/story.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// 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.
//

/// Utilities
.flex {
display: flex;
}

.flex-column {
flex-direction: column;
}

.justify-center {
justify-content: center;
}

.justify-end {
justify-content: flex-end;
}

.align-center {
align-items: center;
}

.align-end {
align-items: flex-end;
}

.justify-items-end {
justify-items: end;
}

.position-relative {
position: relative;
}

.grid {
display: grid;
}

.grid-cols-3 {
grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mb-3 {
margin-bottom: 1rem;
}

.mt-9 {
padding-top: 3rem;
}

.p-3 {
padding: 1rem;
}
Loading

0 comments on commit f71c763

Please sign in to comment.