@dtdot/lego 2.0.0-37 → 2.0.0-39
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/build/components/FloatingActionButton/FloatingActionButton.component.d.ts +10 -0
- package/build/components/FloatingActionButton/FloatingActionButton.component.js +42 -0
- package/build/components/MinimalMenu/MinimalMenu.context.d.ts +7 -0
- package/build/components/MinimalMenu/MinimalMenu.context.js +6 -0
- package/build/components/MinimalMenu/_MinimalMenuPage.component.js +10 -3
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/package.json +1 -1
- package/build/components/FloatingAction/FloatingAction.component.d.ts +0 -7
- package/build/components/FloatingAction/FloatingAction.component.js +0 -11
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
3
|
+
import { ColourVariant } from '../../theme/theme.types';
|
|
4
|
+
interface FloatingActionButtonProps {
|
|
5
|
+
icon: IconDefinition;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
variant?: ColourVariant;
|
|
8
|
+
}
|
|
9
|
+
declare const FloatingActionButton: React.FC<FloatingActionButtonProps>;
|
|
10
|
+
export default FloatingActionButton;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { motion } from 'framer-motion';
|
|
4
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
+
import getThemeVariantColours from '../../theme/helpers/getThemeVariantColours';
|
|
6
|
+
import MinimalMenuContext from '../MinimalMenu/MinimalMenu.context';
|
|
7
|
+
const FloatingButton = styled(motion.button) `
|
|
8
|
+
position: fixed;
|
|
9
|
+
bottom: ${(props) => (props.offsetBottom ? '76px' : '20px')};
|
|
10
|
+
right: 20px;
|
|
11
|
+
width: 56px;
|
|
12
|
+
height: 56px;
|
|
13
|
+
border-radius: 50%;
|
|
14
|
+
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).main};
|
|
15
|
+
color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
16
|
+
border: none;
|
|
17
|
+
outline: none;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
align-items: center;
|
|
22
|
+
font-size: 24px;
|
|
23
|
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
|
|
24
|
+
z-index: 999;
|
|
25
|
+
|
|
26
|
+
&:hover {
|
|
27
|
+
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).darker};
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
const FloatingActionButton = ({ icon, onClick, variant = 'primary' }) => {
|
|
31
|
+
const { menuExists, isMobile } = useContext(MinimalMenuContext);
|
|
32
|
+
const variants = {
|
|
33
|
+
hidden: { opacity: 0, scale: 0 },
|
|
34
|
+
visible: { opacity: 1, scale: 1, transition: { duration: 0.3, delay: 0.2 } },
|
|
35
|
+
exit: { opacity: 0, scale: 0 },
|
|
36
|
+
hover: { scale: 1.05 },
|
|
37
|
+
tap: { scale: 0.95 },
|
|
38
|
+
};
|
|
39
|
+
return (React.createElement(FloatingButton, { initial: 'hidden', animate: 'visible', exit: 'exit', whileHover: 'hover', whileTap: 'tap', offsetBottom: menuExists && isMobile, variants: variants, onClick: onClick, variant: variant },
|
|
40
|
+
React.createElement(FontAwesomeIcon, { icon: icon })));
|
|
41
|
+
};
|
|
42
|
+
export default FloatingActionButton;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import responsive from '../../responsive/responsive';
|
|
3
|
+
import responsive, { useIsScreenSize } from '../../responsive/responsive';
|
|
4
|
+
import MinimalMenuContext from './MinimalMenu.context';
|
|
4
5
|
const MinimalMenuPageContainer = styled.div `
|
|
5
6
|
${responsive.useStylesFor('tablet').andLarger(`
|
|
6
7
|
padding-left: 64px;
|
|
@@ -17,6 +18,12 @@ const MinimalMenuPageContainer = styled.div `
|
|
|
17
18
|
`}
|
|
18
19
|
`;
|
|
19
20
|
const MinimalMenuPage = ({ children, hiddenMenu }) => {
|
|
20
|
-
|
|
21
|
+
const isMobile = useIsScreenSize('mobile');
|
|
22
|
+
const contextState = useMemo(() => ({
|
|
23
|
+
menuExists: true,
|
|
24
|
+
isMobile,
|
|
25
|
+
}), [isMobile]);
|
|
26
|
+
return (React.createElement(MinimalMenuContext.Provider, { value: contextState },
|
|
27
|
+
React.createElement(MinimalMenuPageContainer, { hiddenMenu: !!hiddenMenu }, children)));
|
|
21
28
|
};
|
|
22
29
|
export default MinimalMenuPage;
|
package/build/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { default as Checklist } from './components/Checklist/Checklist.component
|
|
|
14
14
|
export { default as ControlGroup } from './components/ControlGroup/ControlGroup.component';
|
|
15
15
|
export { default as ControlLine } from './components/ControlLine/ControlLine.component';
|
|
16
16
|
export { default as FancyCheckbox } from './components/FancyCheckbox/FancyCheckbox.component';
|
|
17
|
-
export { default as
|
|
17
|
+
export { default as FloatingActionButton } from './components/FloatingActionButton/FloatingActionButton.component';
|
|
18
18
|
export { default as Form } from './components/Form/Form.component';
|
|
19
19
|
export { default as Notification } from './components/Notification/Notification.component';
|
|
20
20
|
export { default as Notifications } from './components/Notifications/Notifications.component';
|
package/build/index.js
CHANGED
|
@@ -14,7 +14,7 @@ export { default as Checklist } from './components/Checklist/Checklist.component
|
|
|
14
14
|
export { default as ControlGroup } from './components/ControlGroup/ControlGroup.component';
|
|
15
15
|
export { default as ControlLine } from './components/ControlLine/ControlLine.component';
|
|
16
16
|
export { default as FancyCheckbox } from './components/FancyCheckbox/FancyCheckbox.component';
|
|
17
|
-
export { default as
|
|
17
|
+
export { default as FloatingActionButton } from './components/FloatingActionButton/FloatingActionButton.component';
|
|
18
18
|
export { default as Form } from './components/Form/Form.component';
|
|
19
19
|
export { default as Notification } from './components/Notification/Notification.component';
|
|
20
20
|
export { default as Notifications } from './components/Notifications/Notifications.component';
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
const FloatingActionContainer = styled.div `
|
|
4
|
-
position: sticky;
|
|
5
|
-
bottom: 0;
|
|
6
|
-
background-color: ${(props) => props.theme.colours.background};
|
|
7
|
-
`;
|
|
8
|
-
const FloatingAction = ({ children }) => {
|
|
9
|
-
return React.createElement(FloatingActionContainer, null, children);
|
|
10
|
-
};
|
|
11
|
-
export default FloatingAction;
|