@newtonschool/grauity 0.0.1
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/CHANGELOG.md +22 -0
- package/LICENSE +674 -0
- package/README.md +15 -0
- package/dist/core/colors/colorTypes.d.ts +3 -0
- package/dist/core/colors/colorTypes.d.ts.map +1 -0
- package/dist/core/colors/index.d.ts +14 -0
- package/dist/core/colors/index.d.ts.map +1 -0
- package/dist/core/icons/iconTags.d.ts +16 -0
- package/dist/core/icons/iconTags.d.ts.map +1 -0
- package/dist/core/icons/iconTypes.d.ts +10 -0
- package/dist/core/icons/iconTypes.d.ts.map +1 -0
- package/dist/core/icons/index.d.ts +4 -0
- package/dist/core/icons/index.d.ts.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/miscellaneous-choices/index.d.ts +12 -0
- package/dist/core/miscellaneous-choices/index.d.ts.map +1 -0
- package/dist/core/miscellaneous-choices/miscellaneousTypes.d.ts +3 -0
- package/dist/core/miscellaneous-choices/miscellaneousTypes.d.ts.map +1 -0
- package/dist/core/sizes/index.d.ts +17 -0
- package/dist/core/sizes/index.d.ts.map +1 -0
- package/dist/core/sizes/sizeTypes.d.ts +3 -0
- package/dist/core/sizes/sizeTypes.d.ts.map +1 -0
- package/dist/elements/Icon/Icon.d.ts +115 -0
- package/dist/elements/Icon/Icon.d.ts.map +1 -0
- package/dist/elements/Icon/index.d.ts +3 -0
- package/dist/elements/Icon/index.d.ts.map +1 -0
- package/dist/elements/index.d.ts +3 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/helpers/classNameBuilders.d.ts +35 -0
- package/dist/helpers/classNameBuilders.d.ts.map +1 -0
- package/dist/helpers/getElementTypeFromProps.d.ts +14 -0
- package/dist/helpers/getElementTypeFromProps.d.ts.map +1 -0
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/init/GrauityInit.d.ts +41 -0
- package/dist/init/GrauityInit.d.ts.map +1 -0
- package/dist/init/index.d.ts +3 -0
- package/dist/init/index.d.ts.map +1 -0
- package/dist/main.cjs +2 -0
- package/dist/main.cjs.map +1 -0
- package/dist/main.css +2 -0
- package/dist/main.css.map +1 -0
- package/dist/module.css +2 -0
- package/dist/module.css.map +1 -0
- package/dist/module.mjs +2 -0
- package/dist/module.mjs.map +1 -0
- package/package.json +158 -0
- package/ui/.gitkeep +0 -0
- package/ui/README.md +3 -0
- package/ui/core/README.md +4 -0
- package/ui/core/colors/colorTypes.d.ts.map +1 -0
- package/ui/core/colors/colorTypes.ts +21 -0
- package/ui/core/colors/index.d.ts.map +1 -0
- package/ui/core/colors/index.ts +25 -0
- package/ui/core/icons/iconTags.d.ts.map +1 -0
- package/ui/core/icons/iconTags.ts +15 -0
- package/ui/core/icons/iconTypes.d.ts.map +1 -0
- package/ui/core/icons/iconTypes.ts +21 -0
- package/ui/core/icons/index.d.ts.map +1 -0
- package/ui/core/icons/index.ts +5 -0
- package/ui/core/index.d.ts.map +1 -0
- package/ui/core/index.ts +17 -0
- package/ui/core/miscellaneous-choices/index.ts +24 -0
- package/ui/core/miscellaneous-choices/miscellaneousTypes.ts +3 -0
- package/ui/core/sizes/index.ts +29 -0
- package/ui/core/sizes/sizeTypes.ts +25 -0
- package/ui/css/animations.scss +8 -0
- package/ui/css/colors.scss +131 -0
- package/ui/css/fonts.scss +17 -0
- package/ui/css/icons.scss +92 -0
- package/ui/css/index.scss +11 -0
- package/ui/css/reset.scss +515 -0
- package/ui/css/sizes.scss +0 -0
- package/ui/elements/Icon/Icon.tsx +229 -0
- package/ui/elements/Icon/index.ts +3 -0
- package/ui/elements/index.ts +2 -0
- package/ui/helpers/README.md +3 -0
- package/ui/helpers/classNameBuilders.ts +48 -0
- package/ui/helpers/getElementTypeFromProps.ts +32 -0
- package/ui/helpers/index.ts +13 -0
- package/ui/index.ts +9 -0
- package/ui/init/GrauityInit.tsx +62 -0
- package/ui/init/index.ts +3 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* There are 3 prop patterns used to build up the className for a component.
|
|
3
|
+
* Each utility here is meant for use in a classnames() argument.
|
|
4
|
+
*
|
|
5
|
+
* There is no util for valueOnly() because it would simply return val.
|
|
6
|
+
* Use the prop value inline instead.
|
|
7
|
+
* <Label size='big' />
|
|
8
|
+
* <div class="ui big label"></div>
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Props where only the prop key is used in the className.
|
|
13
|
+
* @param {*} val A props value
|
|
14
|
+
* @param {string} key A props key
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* <Label tag />
|
|
18
|
+
* <div class="ui tag label"></div>
|
|
19
|
+
*/
|
|
20
|
+
export const useKeyOnly = (val: any, key: string) => val && key;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Props that require both a key and value to create a className.
|
|
24
|
+
* @param {*} val A props value
|
|
25
|
+
* @param {string} key A props key
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* <Label corner='left' />
|
|
29
|
+
* <div class="ui left corner label"></div>
|
|
30
|
+
*/
|
|
31
|
+
export const useValueAndKey = (val: any, key: string) =>
|
|
32
|
+
val && val !== true && `${val}-${key}`;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Props whose key will be used in className, or value and key.
|
|
36
|
+
* @param {*} val A props value
|
|
37
|
+
* @param {string} key A props key
|
|
38
|
+
*
|
|
39
|
+
* @example Key Only
|
|
40
|
+
* <Label pointing />
|
|
41
|
+
* <div class="ui pointing label"></div>
|
|
42
|
+
*
|
|
43
|
+
* @example Key and Value
|
|
44
|
+
* <Label pointing='left' />
|
|
45
|
+
* <div class="ui left pointing label"></div>
|
|
46
|
+
*/
|
|
47
|
+
export const useKeyOrValueAndKey = (val: any, key: string) =>
|
|
48
|
+
val && (val === true ? key : `${val}-${key}`);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns a createElement() type based on the props of the Component.
|
|
6
|
+
* Useful for calculating what type a component should render as.
|
|
7
|
+
*
|
|
8
|
+
* @param {object} props A ReactElement props object
|
|
9
|
+
* @returns {string|function} A ReactElement type
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function getElementTypeFromProps(props: {
|
|
13
|
+
as: React.ElementType;
|
|
14
|
+
href?: string;
|
|
15
|
+
}) {
|
|
16
|
+
// ----------------------------------------
|
|
17
|
+
// user defined "as" element type
|
|
18
|
+
|
|
19
|
+
if (props.as) return styled(props.as)``;
|
|
20
|
+
|
|
21
|
+
// ----------------------------------------
|
|
22
|
+
// infer anchor links
|
|
23
|
+
|
|
24
|
+
if (props.href) return styled('a')``;
|
|
25
|
+
|
|
26
|
+
// ----------------------------------------
|
|
27
|
+
// use defaultProp or 'div'
|
|
28
|
+
|
|
29
|
+
return styled('div')``;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default getElementTypeFromProps;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import getElementTypeFromProps from './getElementTypeFromProps';
|
|
2
|
+
import {
|
|
3
|
+
useKeyOnly,
|
|
4
|
+
useKeyOrValueAndKey,
|
|
5
|
+
useValueAndKey,
|
|
6
|
+
} from './classNameBuilders';
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
useKeyOnly,
|
|
10
|
+
useValueAndKey,
|
|
11
|
+
useKeyOrValueAndKey,
|
|
12
|
+
getElementTypeFromProps,
|
|
13
|
+
};
|
package/ui/index.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { getElementTypeFromProps } from '../helpers';
|
|
5
|
+
|
|
6
|
+
export interface GrauityInitProps {
|
|
7
|
+
/**
|
|
8
|
+
* An element type to render as (string or function).
|
|
9
|
+
* */
|
|
10
|
+
as: React.ElementType;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The font size to be applied on this element and so will act as standard for the `ems` of all grauity components.
|
|
14
|
+
* */
|
|
15
|
+
fontSize: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The multiplier is multiplied will all the `ems` of the grauity components.
|
|
19
|
+
* */
|
|
20
|
+
multiplier?: number;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The children to be rendered inside this component.
|
|
24
|
+
* */
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This component is used to initialize the Grauity library. Ideally, it should be the root component of your application.
|
|
30
|
+
* But nonetheless all the grauity components should be the children of this component.
|
|
31
|
+
* */
|
|
32
|
+
function GrauityInit({ as, fontSize, multiplier, children }: GrauityInitProps) {
|
|
33
|
+
const ElementType = getElementTypeFromProps({ as });
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ElementType
|
|
37
|
+
className="grauity-init"
|
|
38
|
+
style={{
|
|
39
|
+
fontSize,
|
|
40
|
+
'--multiplier': multiplier,
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
</ElementType>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
GrauityInit.propTypes = {
|
|
49
|
+
as: PropTypes.elementType,
|
|
50
|
+
fontSize: PropTypes.string,
|
|
51
|
+
multiplier: PropTypes.number,
|
|
52
|
+
children: PropTypes.node,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
GrauityInit.defaultProps = {
|
|
56
|
+
as: 'div',
|
|
57
|
+
fontSize: '16px',
|
|
58
|
+
multiplier: 1,
|
|
59
|
+
children: null,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default GrauityInit;
|
package/ui/init/index.ts
ADDED