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

Move css to component scope #2168

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

/formik*.js
/formik.js.LICENSE.txt
/index.css
/index*.js
/layouts*.js
/molecules.js
Expand Down
17 changes: 10 additions & 7 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,24 @@ module.exports = {
],

webpackFinal: async config => {
config.resolve.alias = {
...config.resolve.alias,
...rootResolve.alias,
"@bigbinary/neetoui": path.resolve(__dirname, "..", "src"),
config.resolve = {
extensions: [".js", ".jsx", ".svg", ".scss"],
alias: {
...config.resolve.alias,
...rootResolve.alias,
"@bigbinary/neetoui": path.resolve(__dirname, "..", "src"),
},
};

return config;
},

framework: {
name: "@storybook/react-webpack5",
options: {}
options: {},
},

docs: {
autodocs: true
}
autodocs: true,
},
};
10 changes: 1 addition & 9 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "./style.scss";
import "../src/styles/index.scss";
import { themes } from "@storybook/theming";
import neetoTheme from "./neetoTheme";

Expand Down Expand Up @@ -50,14 +49,7 @@ export const parameters = {
],
"Molecules",
"Overlays",
[
"Alert",
"Modal",
"Pane",
"Toastr",
"Tooltip",
"Popover"
],
["Alert", "Modal", "Pane", "Toastr", "Tooltip", "Popover"],
"Formik",
["Form"],
"Customize",
Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@
yarn add @bigbinary/neetoui
```

This would install `neetoui` package inside your application. Starting `3.0.x`,
neetoUI stylesheet has been separated from the bundle. To get the styles
working, please import the neetoUI stylesheet to your main `scss` entry point.

```scss
@import "@bigbinary/neetoui";
```
This would install `neetoui` package inside your application.

## Dependencies

Expand Down
1 change: 1 addition & 0 deletions index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Empty css file for backward compatiability */
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = () => ({
moduleDirectories: ["node_modules", "src"],
moduleNameMapper: {
"^.+\\.(css|less|scss)$": "identity-obj-proxy",
"styles/*": "identity-obj-proxy",
"^@bigbinary/neetoui/(.*)$": path.resolve(__dirname, "src", "$1"),
"neetoicons/logos": path.resolve(
__dirname,
Expand Down
4 changes: 3 additions & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"constants": ["src/constants"],
"constants/*": ["src/constants/*"],
"managers": ["src/managers"],
"managers/*": ["src/managers/*"]
"managers/*": ["src/managers/*"],
"styles": ["src/styles/"],
"styles/*": ["src/styles/*"]
},
"pretty": true,
"experimentalDecorators": true,
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bigbinary/neetoui",
"version": "6.5.13",
"version": "6.6.0-css-beta.1",
"author": "BigBinary",
"license": "MIT",
"description": "neetoUI drives the experience at all neeto products",
Expand All @@ -16,6 +16,7 @@
"files": [
"dist",
"types",
"index.css",
"*.d.ts"
],
"lint-staged": {
Expand All @@ -32,7 +33,7 @@
".": {
"import": "./dist/index.js",
"require": "./dist/cjs/index.js",
"style": "./dist/index.css",
"style": "./index.css",
"types": "./index.d.ts"
},
"./layouts": {
Expand Down
1 change: 1 addition & 0 deletions resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ module.exports = {
managers: path.resolve(__dirname, "./src/managers"),
formikcomponents: path.resolve(__dirname, "./src/formik"),
layouts: path.resolve(__dirname, "./src/layouts"),
styles: path.resolve(__dirname, "./src/styles"),
},
};
5 changes: 3 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ const config = args => {
babel({ exclude: "node_modules/**", babelHelpers: "runtime" }),
resolve({
preferBuiltins: true,
extensions: [".js", ".jsx", ".svg"],
extensions: [".js", ".jsx", ".svg", ".scss"],
moduleDirectories: ["node_modules"],
}),
commonjs({ include: /\**node_modules\**/ }),
json(),
styles({
extensions: [".css", ".scss", ".min.css"],
mode: ["extract", "index.css"],
minimize: true,
}),
args.app &&
copy({
Expand All @@ -56,6 +56,7 @@ const config = args => {
{ src: "index.d.ts", dest: destination },
{ src: "formik.d.ts", dest: destination },
{ src: "managers.d.ts", dest: destination },
{ src: "index.css", dest: destination },
{ src: "types/", dest: destination },
],
}),
Expand Down
3 changes: 3 additions & 0 deletions src/components/Accordion/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import classnames from "classnames";
import PropTypes from "prop-types";
import { isEmpty } from "ramda";

import "styles/common";
import "styles/components/_accordion";

import Item from "./Item";

const ACCORDION_STYLES = {
Expand Down
13 changes: 5 additions & 8 deletions src/components/ActionDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import React from "react";
import classnames from "classnames";
import PropTypes from "prop-types";

import "styles/common";
import "styles/components/_action-dropdown";
import { noop } from "utils";

import Button from "./Button";
import Dropdown from "./Dropdown";

const BTN_STYLES = {
primary: "primary",
secondary: "secondary",
};
const BTN_STYLES = { primary: "primary", secondary: "secondary" };

const BTN_SIZES = {
small: "small",
Expand All @@ -32,18 +31,16 @@ const ActionDropdown = ({
}) => (
<div className={classnames(["neeto-ui-action-dropdown", className])}>
<Button
{...{ disabled, label, onClick }}
data-testid="action-dropdown-btn"
disabled={disabled}
label={label}
size={size ?? buttonSize}
style={style ?? buttonStyle}
onClick={onClick}
{...buttonProps}
/>
<Dropdown
{...{ disabled }}
buttonProps={{ size: size ?? buttonSize }}
buttonStyle={style ?? buttonStyle}
disabled={disabled}
{...dropdownProps}
>
{children}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Avatar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import PropTypes from "prop-types";
import { isNil } from "ramda";

import Tooltip from "components/Tooltip";
import "styles/common";
import "styles/components/_avatar";

import { COLOR_PALLETE, AVATAR_VARIANT } from "./constants";

Expand Down
2 changes: 2 additions & 0 deletions src/components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import PropTypes from "prop-types";
import { Link } from "react-router-dom";

import Spinner from "atoms/Spinner";
import "styles/common";
import "styles/components/_button";

import Tooltip from "./Tooltip";

Expand Down
3 changes: 3 additions & 0 deletions src/components/Callout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import React from "react";
import classnames from "classnames";
import PropTypes from "prop-types";

import "styles/common";
import "styles/components/_callout";

const STYLES = {
info: "info",
warning: "warning",
Expand Down
2 changes: 2 additions & 0 deletions src/components/Checkbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import classnames from "classnames";
import PropTypes from "prop-types";

import { useId } from "hooks";
import "styles/common";
import "styles/components/_checkbox";
import { hyphenize } from "utils";

import Label from "./Label";
Expand Down
2 changes: 2 additions & 0 deletions src/components/ColorPicker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import useEyeDropper from "use-eye-dropper";

import Button from "components/Button";
import Dropdown from "components/Dropdown";
import "styles/common";
import "styles/components/_color-picker";
import { noop } from "utils";

import Palette from "./Palette";
Expand Down
2 changes: 2 additions & 0 deletions src/components/DatePicker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import PropTypes from "prop-types";

import Label from "components/Label";
import { useSyncedRef, useId } from "hooks";
import "styles/common";
import "styles/components/_date-time-picker";
import { convertToDayjsObjects, noop, hyphenize } from "utils";

import IconOverride from "./IconOverride";
Expand Down
2 changes: 2 additions & 0 deletions src/components/Dropdown/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import PropTypes from "prop-types";
import { isNil } from "ramda";

import Button from "components/Button";
import "styles/common";
import "styles/components/_dropdown";
import { hyphenize, noop } from "utils";

import Divider from "./Divider";
Expand Down
2 changes: 2 additions & 0 deletions src/components/Input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import PropTypes from "prop-types";
import { replace } from "ramda";

import { useId } from "hooks";
import "styles/common";
import "styles/components/_input";
import { hyphenize } from "utils";

import Label from "./Label";
Expand Down
3 changes: 3 additions & 0 deletions src/components/Kbd.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import React from "react";
import classnames from "classnames";
import PropTypes from "prop-types";

import "styles/common";
import "styles/components/_kbd";

import Tooltip from "./Tooltip";

const Kbd = ({ keyName, className, tooltipProps, ...otherProps }) => (
Expand Down
3 changes: 3 additions & 0 deletions src/components/Label.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import classnames from "classnames";
import { Help } from "neetoicons";
import PropTypes from "prop-types";

import "styles/common";
import "styles/components/_label";

import Tooltip from "./Tooltip";

const Label = ({
Expand Down
2 changes: 2 additions & 0 deletions src/components/Modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Backdrop from "atoms/Backdrop";
import Portal from "atoms/Portal";
import Button from "components/Button";
import { useOverlayManager, useOverlay } from "hooks";
import "styles/common";
import "styles/components/_modal";

import Body from "./Body";
import Footer from "./Footer";
Expand Down
2 changes: 2 additions & 0 deletions src/components/MultiEmailInput/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import PropTypes from "prop-types";
import { mergeLeft, isEmpty } from "ramda";
import CreatableSelect from "react-select/creatable";

import "styles/common";
import "styles/components/_email-input";
import { noop, hyphenize } from "utils";

import {
Expand Down
2 changes: 2 additions & 0 deletions src/components/NoData/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { isEmpty } from "ramda";

import Button from "components/Button";
import Typography from "components/Typography";
import "styles/common";
import "styles/components/_no-data";

import { renderImage } from "./utils";

Expand Down
3 changes: 3 additions & 0 deletions src/components/Pagination/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import classnames from "classnames";
import { Left, Right } from "neetoicons";
import PropTypes from "prop-types";

import "styles/common";
import "styles/components/_pagination";

import { DOTS } from "./constants";
import usePaginationQueryParams from "./hooks/usePaginationQueryParams";
import { usePagination } from "./utils";
Expand Down
2 changes: 2 additions & 0 deletions src/components/Pane/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Backdrop from "atoms/Backdrop";
import Portal from "atoms/Portal";
import Button from "components/Button";
import { useOverlay, useOverlayManager } from "hooks";
import "styles/common";
import "styles/components/_pane";

import Body from "./Body";
import { DEFAULT_PANE_HEADER_HEIGHT } from "./constants";
Expand Down
3 changes: 3 additions & 0 deletions src/components/Popover/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import React from "react";
import classnames from "classnames";
import PropTypes from "prop-types";

import "styles/common";
import "styles/components/_popover";

import Title from "./Title";

import Tooltip from "../Tooltip";
Expand Down
2 changes: 2 additions & 0 deletions src/components/Radio/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import PropTypes from "prop-types";

import Label from "components/Label";
import { useId } from "hooks";
import "styles/common";
import "styles/components/_radio";
import { hyphenize } from "utils";

import Item from "./Item";
Expand Down
2 changes: 2 additions & 0 deletions src/components/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import AsyncCreatable from "react-select/async-creatable";
import Creatable from "react-select/creatable";

import { useId } from "hooks";
import "styles/common";
import "styles/components/_select";
import { hyphenize } from "utils";

import Label from "./Label";
Expand Down
2 changes: 2 additions & 0 deletions src/components/Slider/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import PropTypes from "prop-types";

import Label from "components/Label";
import { useId } from "hooks";
import "styles/common";
import "styles/components/_slider";
import { ANT_DESIGN_GLOBAL_TOKEN_OVERRIDES, hyphenize, noop } from "utils";

import { NEETO_UI_PRIMARY_500 } from "./constants";
Expand Down
3 changes: 3 additions & 0 deletions src/components/Spinner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import React from "react";
import classnames from "classnames";
import PropTypes from "prop-types";

import "styles/common";
import "styles/components/_spinner";

const SPINNER_THEMES = { dark: "dark", light: "light" };
const SPINNER_SIZES = { small: "small", medium: "medium" };

Expand Down
Loading
Loading