@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.
Files changed (86) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/LICENSE +674 -0
  3. package/README.md +15 -0
  4. package/dist/core/colors/colorTypes.d.ts +3 -0
  5. package/dist/core/colors/colorTypes.d.ts.map +1 -0
  6. package/dist/core/colors/index.d.ts +14 -0
  7. package/dist/core/colors/index.d.ts.map +1 -0
  8. package/dist/core/icons/iconTags.d.ts +16 -0
  9. package/dist/core/icons/iconTags.d.ts.map +1 -0
  10. package/dist/core/icons/iconTypes.d.ts +10 -0
  11. package/dist/core/icons/iconTypes.d.ts.map +1 -0
  12. package/dist/core/icons/index.d.ts +4 -0
  13. package/dist/core/icons/index.d.ts.map +1 -0
  14. package/dist/core/index.d.ts +9 -0
  15. package/dist/core/index.d.ts.map +1 -0
  16. package/dist/core/miscellaneous-choices/index.d.ts +12 -0
  17. package/dist/core/miscellaneous-choices/index.d.ts.map +1 -0
  18. package/dist/core/miscellaneous-choices/miscellaneousTypes.d.ts +3 -0
  19. package/dist/core/miscellaneous-choices/miscellaneousTypes.d.ts.map +1 -0
  20. package/dist/core/sizes/index.d.ts +17 -0
  21. package/dist/core/sizes/index.d.ts.map +1 -0
  22. package/dist/core/sizes/sizeTypes.d.ts +3 -0
  23. package/dist/core/sizes/sizeTypes.d.ts.map +1 -0
  24. package/dist/elements/Icon/Icon.d.ts +115 -0
  25. package/dist/elements/Icon/Icon.d.ts.map +1 -0
  26. package/dist/elements/Icon/index.d.ts +3 -0
  27. package/dist/elements/Icon/index.d.ts.map +1 -0
  28. package/dist/elements/index.d.ts +3 -0
  29. package/dist/elements/index.d.ts.map +1 -0
  30. package/dist/helpers/classNameBuilders.d.ts +35 -0
  31. package/dist/helpers/classNameBuilders.d.ts.map +1 -0
  32. package/dist/helpers/getElementTypeFromProps.d.ts +14 -0
  33. package/dist/helpers/getElementTypeFromProps.d.ts.map +1 -0
  34. package/dist/helpers/index.d.ts +4 -0
  35. package/dist/helpers/index.d.ts.map +1 -0
  36. package/dist/index.d.ts +7 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/init/GrauityInit.d.ts +41 -0
  39. package/dist/init/GrauityInit.d.ts.map +1 -0
  40. package/dist/init/index.d.ts +3 -0
  41. package/dist/init/index.d.ts.map +1 -0
  42. package/dist/main.cjs +2 -0
  43. package/dist/main.cjs.map +1 -0
  44. package/dist/main.css +2 -0
  45. package/dist/main.css.map +1 -0
  46. package/dist/module.css +2 -0
  47. package/dist/module.css.map +1 -0
  48. package/dist/module.mjs +2 -0
  49. package/dist/module.mjs.map +1 -0
  50. package/package.json +158 -0
  51. package/ui/.gitkeep +0 -0
  52. package/ui/README.md +3 -0
  53. package/ui/core/README.md +4 -0
  54. package/ui/core/colors/colorTypes.d.ts.map +1 -0
  55. package/ui/core/colors/colorTypes.ts +21 -0
  56. package/ui/core/colors/index.d.ts.map +1 -0
  57. package/ui/core/colors/index.ts +25 -0
  58. package/ui/core/icons/iconTags.d.ts.map +1 -0
  59. package/ui/core/icons/iconTags.ts +15 -0
  60. package/ui/core/icons/iconTypes.d.ts.map +1 -0
  61. package/ui/core/icons/iconTypes.ts +21 -0
  62. package/ui/core/icons/index.d.ts.map +1 -0
  63. package/ui/core/icons/index.ts +5 -0
  64. package/ui/core/index.d.ts.map +1 -0
  65. package/ui/core/index.ts +17 -0
  66. package/ui/core/miscellaneous-choices/index.ts +24 -0
  67. package/ui/core/miscellaneous-choices/miscellaneousTypes.ts +3 -0
  68. package/ui/core/sizes/index.ts +29 -0
  69. package/ui/core/sizes/sizeTypes.ts +25 -0
  70. package/ui/css/animations.scss +8 -0
  71. package/ui/css/colors.scss +131 -0
  72. package/ui/css/fonts.scss +17 -0
  73. package/ui/css/icons.scss +92 -0
  74. package/ui/css/index.scss +11 -0
  75. package/ui/css/reset.scss +515 -0
  76. package/ui/css/sizes.scss +0 -0
  77. package/ui/elements/Icon/Icon.tsx +229 -0
  78. package/ui/elements/Icon/index.ts +3 -0
  79. package/ui/elements/index.ts +2 -0
  80. package/ui/helpers/README.md +3 -0
  81. package/ui/helpers/classNameBuilders.ts +48 -0
  82. package/ui/helpers/getElementTypeFromProps.ts +32 -0
  83. package/ui/helpers/index.ts +13 -0
  84. package/ui/index.ts +9 -0
  85. package/ui/init/GrauityInit.tsx +62 -0
  86. package/ui/init/index.ts +3 -0
@@ -0,0 +1,3 @@
1
+ export type { IconProps } from './Icon';
2
+
3
+ export { default as Icon } from './Icon';
@@ -0,0 +1,2 @@
1
+ export type { IconProps } from './Icon';
2
+ export { Icon } from './Icon';
@@ -0,0 +1,3 @@
1
+ # helpers
2
+
3
+ The purpose fo the directory is to contain all the common utils required by the library
@@ -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,9 @@
1
+ import './css/index.scss';
2
+
3
+ export { ICON_TAGS, TAG_ICONS } from './core';
4
+
5
+ export type { GrauityInitProps } from './init';
6
+ export { GrauityInit } from './init';
7
+
8
+ export type { IconProps } from './elements';
9
+ export { Icon } from './elements';
@@ -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;
@@ -0,0 +1,3 @@
1
+ export type { GrauityInitProps } from './GrauityInit';
2
+
3
+ export { default as GrauityInit } from './GrauityInit';