@lanaco/lnc-react-ui 2.1.42 → 3.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +39 -39
- package/custom-addons/ThemeSelector.js +111 -0
- package/custom-addons/register.js +16 -0
- package/custom-addons/theme-selector.css +17 -0
- package/jest.config.js +7 -0
- package/lib/index.esm.js +79661 -42410
- package/lib/index.js +79572 -42269
- package/package.json +91 -68
- package/rc1 +0 -0
- package/test/jest/__mocks__/styleMock.js +1 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Lanaco
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Lanaco
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
# Lanaco ReactJS UI components library
|
|
2
|
-
|
|
3
|
-
This library includes basic and advanced UI components used with ReactJS frontend framework
|
|
4
|
-
|
|
5
|
-
- [Installing](#installing)
|
|
6
|
-
- [Developing Locally](#requirements)
|
|
7
|
-
- [Contributing](#contributing)
|
|
8
|
-
- [License](#license)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Installing
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
$ npm install --save-dev @lanaco/lnc-react-ui
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Developing Locally
|
|
19
|
-
|
|
20
|
-
To see your changes to `@lanaco/lnc-react-ui` locally, all you need is to run storybook with `npm start` command
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
$ git clone https://github.com/lanaco/lnc-react-ui
|
|
24
|
-
$ cd /path/to/component-library
|
|
25
|
-
$ npm start
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Contributing
|
|
29
|
-
|
|
30
|
-
1. Clone this repo
|
|
31
|
-
2. Create a branch: `git checkout -b your-feature`
|
|
32
|
-
3. Make some changes
|
|
33
|
-
4. Test your changes by [running your local version](#requirements)
|
|
34
|
-
5. Push your branch and open a Pull Request
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## License
|
|
38
|
-
|
|
39
|
-
This code is open source software licensed under the MIT License.
|
|
1
|
+
# Lanaco ReactJS UI components library
|
|
2
|
+
|
|
3
|
+
This library includes basic and advanced UI components used with ReactJS frontend framework
|
|
4
|
+
|
|
5
|
+
- [Installing](#installing)
|
|
6
|
+
- [Developing Locally](#requirements)
|
|
7
|
+
- [Contributing](#contributing)
|
|
8
|
+
- [License](#license)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Installing
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
$ npm install --save-dev @lanaco/lnc-react-ui
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Developing Locally
|
|
19
|
+
|
|
20
|
+
To see your changes to `@lanaco/lnc-react-ui` locally, all you need is to run storybook with `npm start` command
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
$ git clone https://github.com/lanaco/lnc-react-ui
|
|
24
|
+
$ cd /path/to/component-library
|
|
25
|
+
$ npm start
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Contributing
|
|
29
|
+
|
|
30
|
+
1. Clone this repo
|
|
31
|
+
2. Create a branch: `git checkout -b your-feature`
|
|
32
|
+
3. Make some changes
|
|
33
|
+
4. Test your changes by [running your local version](#requirements)
|
|
34
|
+
5. Push your branch and open a Pull Request
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
This code is open source software licensed under the MIT License.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// OutlineSelector.js
|
|
2
|
+
|
|
3
|
+
import React, { memo, useState } from "react";
|
|
4
|
+
import { useGlobals } from "@storybook/api";
|
|
5
|
+
import {
|
|
6
|
+
Icons,
|
|
7
|
+
IconButton,
|
|
8
|
+
} from "@storybook/components";
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
10
|
+
import { useRef } from "react";
|
|
11
|
+
import styled from "@emotion/styled";
|
|
12
|
+
import { themes } from "../src/_utils/theme";
|
|
13
|
+
import "./theme-selector.css"
|
|
14
|
+
|
|
15
|
+
const StyledTooltip = styled.div`
|
|
16
|
+
position: absolute;
|
|
17
|
+
width: 180px;
|
|
18
|
+
z-index: 2147483647;
|
|
19
|
+
filter: drop-shadow(0px 5px 5px rgba(0, 0, 0, 0.05))
|
|
20
|
+
drop-shadow(0 1px 3px rgba(0, 0, 0, 0.1));
|
|
21
|
+
border-radius: 8px;
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
const Item = styled.div`
|
|
26
|
+
padding: 7px 15px;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
font-weight: 400;
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const Triangle = styled.div`
|
|
32
|
+
position: absolute;
|
|
33
|
+
border-style: solid;
|
|
34
|
+
-webkit-transform: translate3d(8px, 0px, 0px);
|
|
35
|
+
-moz-transform: translate3d(8px, 0px, 0px);
|
|
36
|
+
-ms-transform: translate3d(8px, 0px, 0px);
|
|
37
|
+
transform: translate3d(8px, 0px, 0px);
|
|
38
|
+
bottom: autopx;
|
|
39
|
+
top: -8px;
|
|
40
|
+
right: autopx;
|
|
41
|
+
left: autopx;
|
|
42
|
+
border-bottom-width: 8px;
|
|
43
|
+
border-top-width: 0px;
|
|
44
|
+
border-right-width: 8px;
|
|
45
|
+
border-left-width: 8px;
|
|
46
|
+
border-top-color: transparent;
|
|
47
|
+
border-left-color: transparent;
|
|
48
|
+
border-right-color: transparent;
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
export const ThemeSelector = memo(() => {
|
|
52
|
+
const [globals, updateGlobals] = useGlobals();
|
|
53
|
+
const buttonRef = useRef();
|
|
54
|
+
const [toggleTooltip, setToggleTooltip] = useState();
|
|
55
|
+
|
|
56
|
+
const changeTheme = (themeName) => {
|
|
57
|
+
setToggleTooltip((prev) => !prev);
|
|
58
|
+
updateGlobals({
|
|
59
|
+
theme: themeName,
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div ref={buttonRef}>
|
|
65
|
+
<IconButton
|
|
66
|
+
style={{ position: "relative" }}
|
|
67
|
+
key="outline"
|
|
68
|
+
active={globals["theme"]}
|
|
69
|
+
title="Apply themes to the preview"
|
|
70
|
+
onClick={() => setToggleTooltip((prev) => !prev)}
|
|
71
|
+
>
|
|
72
|
+
<Icons icon="photo" />
|
|
73
|
+
</IconButton>
|
|
74
|
+
{toggleTooltip &&
|
|
75
|
+
createPortal(
|
|
76
|
+
<>
|
|
77
|
+
<Triangle
|
|
78
|
+
className="tooltip-triangle-lnc"
|
|
79
|
+
style={{
|
|
80
|
+
position: "absolute",
|
|
81
|
+
transform: "translate(74px)",
|
|
82
|
+
top: buttonRef?.current?.getBoundingClientRect()?.bottom + 5,
|
|
83
|
+
left: buttonRef?.current?.getBoundingClientRect()?.left - 70,
|
|
84
|
+
}}
|
|
85
|
+
></Triangle>
|
|
86
|
+
<StyledTooltip
|
|
87
|
+
className="tooltip-lnc"
|
|
88
|
+
style={{
|
|
89
|
+
top: buttonRef?.current?.getBoundingClientRect()?.bottom + 12,
|
|
90
|
+
left: buttonRef?.current?.getBoundingClientRect()?.left - 90,
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
{themes.map((theme, i) => (
|
|
94
|
+
<Item
|
|
95
|
+
key={i}
|
|
96
|
+
style={{
|
|
97
|
+
color:
|
|
98
|
+
globals["theme"] === theme?.name ? "#FF4785" : "unset",
|
|
99
|
+
}}
|
|
100
|
+
onClick={() => changeTheme(theme?.name)}
|
|
101
|
+
>
|
|
102
|
+
{theme?.name}
|
|
103
|
+
</Item>
|
|
104
|
+
))}
|
|
105
|
+
</StyledTooltip>
|
|
106
|
+
</>,
|
|
107
|
+
document.body
|
|
108
|
+
)}
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { addons, types } from '@storybook/addons';
|
|
4
|
+
|
|
5
|
+
import { ThemeSelector } from './ThemeSelector';
|
|
6
|
+
|
|
7
|
+
const ADDON_ID = 'smyaddon';
|
|
8
|
+
|
|
9
|
+
addons.register(ADDON_ID, () => {
|
|
10
|
+
addons.add(ADDON_ID, {
|
|
11
|
+
title: 'Theme',
|
|
12
|
+
type: types.TOOL,
|
|
13
|
+
match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),
|
|
14
|
+
render: () => <ThemeSelector />,
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.dark .tooltip-lnc {
|
|
2
|
+
background: rgba(0, 0, 0, 0.95);
|
|
3
|
+
color: white;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.light .tooltip-lnc{
|
|
7
|
+
background: rgba(255,255,255,0.95);
|
|
8
|
+
color: black;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.dark .tooltip-triangle-lnc {
|
|
12
|
+
border-bottom-color: rgba(0, 0, 0, 0.95);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.light .tooltip-triangle-lnc{
|
|
16
|
+
border-bottom-color: rgba(255,255,255,0.95);
|
|
17
|
+
}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//Jest is hitting CSS imports and trying to parse them as if they were JavaScript.
|
|
2
|
+
//The moduleNameMapper setting tells Jest how to interpret files with different extensions.
|
|
3
|
+
module.exports = {
|
|
4
|
+
moduleNameMapper: {
|
|
5
|
+
'\\.(css|less)$': '<rootDir>/test/jest/__mocks__/styleMock.js',
|
|
6
|
+
},
|
|
7
|
+
};
|