this.gui 1.0.16 → 1.0.17

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 (91) hide show
  1. package/README.md +191 -23
  2. package/dist/style.css +1 -1
  3. package/dist/this-gui.es.js +2777 -1923
  4. package/dist/this-gui.umd.js +23 -23
  5. package/package.json +2 -4
  6. package/src/App.jsx +4 -1
  7. package/src/Page.jsx +28 -0
  8. package/src/example.json +43 -0
  9. package/src/scripts/ComponentRegistry.js +70 -0
  10. package/src/scripts/postinstall.js +40 -1
  11. package/src/scripts/renderComponents.js +11 -0
  12. package/src/stories/Atoms/Badge/Badge.css +1 -0
  13. package/src/stories/Atoms/Badge/Badge.stories.jsx +1 -0
  14. package/src/stories/Atoms/Grid/Grid.css +160 -0
  15. package/src/stories/Atoms/Grid/Grid.jsx +43 -0
  16. package/src/stories/Atoms/Grid/Grid.stories.jsx +84 -0
  17. package/src/stories/Atoms/ProgressBar/ProgressBar.css +1 -1
  18. package/src/stories/Atoms/ProgressBar/ProgressBar.jsx +1 -1
  19. package/src/stories/Atoms/ProgressBar/ProgressBar.stories.jsx +1 -1
  20. package/src/stories/Atoms/Section/Section.css +268 -0
  21. package/src/stories/Atoms/Section/Section.jsx +63 -0
  22. package/src/stories/Atoms/Section/Section.stories.jsx +46 -0
  23. package/src/stories/Atoms/TextArea/TextArea.css +1 -0
  24. package/src/stories/Atoms/TextArea/TextArea.jsx +1 -0
  25. package/src/stories/Atoms/TextArea/TextArea.stories.jsx +1 -0
  26. package/src/stories/Atoms/TextInput/TextInput.css +1 -0
  27. package/src/stories/Atoms/TextInput/TextInput.jsx +1 -0
  28. package/src/stories/Atoms/TextInput/TextInput.stories.jsx +1 -0
  29. package/src/stories/Atoms/Toggle/Toggle.css +1 -0
  30. package/src/stories/Atoms/Toggle/Toggle.jsx +1 -0
  31. package/src/stories/Atoms/Toggle/Toggle.stories.jsx +1 -0
  32. package/src/stories/Atoms/Tooltip/Tooltip.css +1 -0
  33. package/src/stories/Atoms/Tooltip/Tooltip.jsx +1 -0
  34. package/src/stories/Atoms/Tooltip/Tooltip.stories.jsx +1 -0
  35. package/src/stories/Atoms/Video/Video.css +1 -0
  36. package/src/stories/Atoms/Video/Video.jsx +1 -0
  37. package/src/stories/Atoms/Video/Video.stories.jsx +1 -0
  38. package/src/stories/Atoms/index.js +4 -0
  39. package/src/stories/Atoms/meta_Atoms.js +4 -1
  40. package/src/stories/Layouts/Accordion/Accordion.css +285 -8
  41. package/src/stories/Layouts/Accordion/Accordion.jsx +62 -19
  42. package/src/stories/Layouts/Accordion/Accordion.stories.jsx +30 -19
  43. package/src/stories/Layouts/index.js +0 -6
  44. package/src/stories/Layouts/meta_Layouts.js +2 -5
  45. package/src/stories/Molecules/Accordion/Accordion.css +1 -1
  46. package/src/stories/Molecules/Accordion/Accordion.jsx +1 -1
  47. package/src/stories/Molecules/Accordion/Accordion.stories.jsx +1 -1
  48. package/src/stories/Molecules/AudioPlayer/AudioPlayer.css +95 -2
  49. package/src/stories/Molecules/AudioPlayer/AudioPlayer.jsx +232 -13
  50. package/src/stories/Molecules/AudioPlayer/AudioPlayer.stories.jsx +46 -11
  51. package/src/stories/Molecules/AvatarWithName/AvatarWithName.css +128 -2
  52. package/src/stories/Molecules/AvatarWithName/AvatarWithName.jsx +69 -14
  53. package/src/stories/Molecules/AvatarWithName/AvatarWithName.stories.jsx +12 -12
  54. package/src/stories/Molecules/Breadcrumbs/Breadcrumbs.css +145 -2
  55. package/src/stories/Molecules/Breadcrumbs/Breadcrumbs.jsx +39 -13
  56. package/src/stories/Molecules/Breadcrumbs/Breadcrumbs.stories.jsx +27 -11
  57. package/src/stories/Molecules/ButtonGroup/ButtonGroup.css +463 -2
  58. package/src/stories/Molecules/ButtonGroup/ButtonGroup.jsx +34 -12
  59. package/src/stories/Molecules/ButtonGroup/ButtonGroup.stories.jsx +36 -12
  60. package/src/stories/Molecules/Card/Card.css +39 -2
  61. package/src/stories/Molecules/Card/Card.jsx +80 -13
  62. package/src/stories/Molecules/Card/Card.stories.jsx +27 -13
  63. package/src/stories/Molecules/ComparisonTable/ComparisonTable.css +33 -2
  64. package/src/stories/Molecules/ComparisonTable/ComparisonTable.jsx +91 -12
  65. package/src/stories/Molecules/ComparisonTable/ComparisonTable.stories.jsx +73 -12
  66. package/src/stories/Molecules/Dropdown/Dropdown.css +192 -0
  67. package/src/stories/Molecules/Dropdown/Dropdown.jsx +96 -0
  68. package/src/stories/Molecules/Dropdown/Dropdown.stories.jsx +45 -0
  69. package/src/stories/Molecules/index.js +2 -1
  70. package/src/stories/Molecules/meta_Molecules.js +6 -3
  71. package/dist/Styles.md +0 -446
  72. package/dist/context.md +0 -942
  73. package/src/Theme.jsx +0 -28
  74. package/src/components/CodeBlock.jsx +0 -22
  75. package/src/components/ComponentFactory.jsx +0 -36
  76. package/src/components/ComponentRegistry.js +0 -21
  77. package/src/scripts/generateComponents.js +0 -166
  78. package/src/scripts/verifyLayouts.js +0 -175
  79. package/src/scripts/verifyMolecules.js +0 -158
  80. package/src/scripts/verifyTemplates.js +0 -154
  81. package/src/scripts/verify_and_install_atoms.js +0 -211
  82. package/src/stories/Layouts/DropdownMenu/DropdownMenu.css +0 -16
  83. package/src/stories/Layouts/DropdownMenu/DropdownMenu.jsx +0 -31
  84. package/src/stories/Layouts/DropdownMenu/DropdownMenu.stories.jsx +0 -28
  85. package/src/stories/Layouts/Grid/Grid.css +0 -4
  86. package/src/stories/Layouts/Grid/Grid.jsx +0 -13
  87. package/src/stories/Layouts/Grid/Grid.stories.jsx +0 -28
  88. package/src/stories/Layouts/Section/Section.css +0 -16
  89. package/src/stories/Layouts/Section/Section.jsx +0 -31
  90. package/src/stories/Layouts/Section/Section.stories.jsx +0 -28
  91. /package/src/themes/{README.md → README_Styles.md} +0 -0
@@ -1,25 +1,92 @@
1
-
2
- import React from 'react';
1
+ //this.GUI/src/stories/Molecules/Card/Card.jsx
2
+ import React, { useState } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import './Card.css';
5
5
 
6
- /**
7
- * Card component
8
- */
9
- export const Card = (props) => {
6
+ export const Card = ({
7
+ children,
8
+ variant,
9
+ color,
10
+ textColor,
11
+ isExpandable,
12
+ isRemovable,
13
+ hoverable,
14
+ width,
15
+ ...props
16
+ }) => {
17
+ const [isExpanded, setIsExpanded] = useState(false);
18
+ const [isVisible, setIsVisible] = useState(true);
19
+
20
+ const handleExpandToggle = () => setIsExpanded(!isExpanded);
21
+ const handleRemove = () => setIsVisible(false);
22
+
23
+ if (!isVisible) return null;
24
+
10
25
  return (
11
- <div className="card" {...props}>
12
- {/* Component implementation */}
26
+ <div
27
+ className={`card card--${variant} ${hoverable ? 'card--hoverable' : ''}`}
28
+ style={{
29
+ backgroundColor: variant === 'solid' ? `var(--${color})` : 'transparent',
30
+ border: variant === 'outline' ? `1px solid var(--${color})` : 'none',
31
+ width: width,
32
+ }}
33
+ {...props}
34
+ >
35
+ {isExpandable && (
36
+ <button className="card__expand" onClick={handleExpandToggle}>
37
+ {isExpanded ? 'Close' : 'Expand'}
38
+ </button>
39
+ )}
40
+
41
+ {isRemovable && (
42
+ <button className="card__remove" onClick={handleRemove}>
43
+ &times;
44
+ </button>
45
+ )}
46
+
47
+ <div
48
+ className="card__content"
49
+ style={{
50
+ color: `var(--${textColor})`, // Apply the text color using CSS variables
51
+ }}
52
+ >
53
+ {children}
54
+ </div>
55
+
56
+ {isExpanded && (
57
+ <div className="card__expanded-content">
58
+ {children}
59
+ </div>
60
+ )}
13
61
  </div>
14
62
  );
15
63
  };
16
64
 
17
65
  Card.propTypes = {
18
- // Define prop types here
66
+ children: PropTypes.node.isRequired,
67
+ variant: PropTypes.oneOf(['solid', 'outline']), // Variant can be 'solid' or 'outline'
68
+ color: PropTypes.oneOf([
69
+ 'primary-color', 'secondary-color', 'info-color', 'warning-color', 'alert-color', 'success-color', 'neutral-color', 'dark-color',
70
+ 'classy-color-1', 'classy-color-2', 'classy-color-3', 'classy-color-4', 'classy-color-5', 'small-switch-color-1', 'small-switch-color-2',
71
+ 'natural-color-1', 'natural-color-2', 'natural-color-3', 'grey-friend-1', 'grey-friend-2', 'shade-1', 'shade-2', 'shade-3', 'shade-4'
72
+ ]).isRequired,
73
+ textColor: PropTypes.oneOf([
74
+ 'primary-color', 'secondary-color', 'info-color', 'warning-color', 'alert-color', 'success-color', 'neutral-color', 'dark-color',
75
+ 'classy-color-1', 'classy-color-2', 'classy-color-3', 'classy-color-4', 'classy-color-5', 'small-switch-color-1', 'small-switch-color-2',
76
+ 'natural-color-1', 'natural-color-2', 'natural-color-3', 'grey-friend-1', 'grey-friend-2', 'shade-1', 'shade-2', 'shade-3', 'shade-4'
77
+ ]), // Separate text color prop
78
+ isExpandable: PropTypes.bool,
79
+ isRemovable: PropTypes.bool,
80
+ hoverable: PropTypes.bool,
81
+ width: PropTypes.string, // Width of the card
19
82
  };
20
83
 
21
84
  Card.defaultProps = {
22
- // Define default props here
23
- };
24
-
25
- export default Card;
85
+ variant: 'solid',
86
+ color: 'neutral-color', // Default background/border color
87
+ textColor: 'dark-color', // Default text color
88
+ isExpandable: false,
89
+ isRemovable: false,
90
+ hoverable: false,
91
+ width: '100%', // Default width
92
+ };
@@ -1,20 +1,34 @@
1
-
1
+ //this.GUI/src/stories/Molecules/Card/Card.stories.jsx
2
+ import React from 'react';
2
3
  import { Card } from './Card';
3
4
 
4
- // Storybook configuration for Card component
5
5
  export default {
6
- title: 'Molecules/ContentDisplay/Card',
6
+ title: 'Molecules/Display/Card',
7
7
  component: Card,
8
- parameters: {
9
- layout: 'centered',
10
- },
11
- argTypes: {
12
- // Define argTypes here
13
- },
14
8
  };
15
9
 
16
- export const Default = {
17
- args: {
18
- // Define default args here
19
- },
10
+ export const SolidCard = (args) => (
11
+ <Card {...args}>
12
+ <h2>Solid Card Example</h2>
13
+ <p>This is a solid card.</p>
14
+ </Card>
15
+ );
16
+
17
+ SolidCard.args = {
18
+ variant: 'solid',
19
+ color: 'primary-color',
20
+ textColor: 'secondary-color',
20
21
  };
22
+
23
+ export const OutlinedCard = (args) => (
24
+ <Card {...args}>
25
+ <h2>Outlined Card Example</h2>
26
+ <p>This is an outlined card.</p>
27
+ </Card>
28
+ );
29
+
30
+ OutlinedCard.args = {
31
+ variant: 'outline',
32
+ color: 'primary-color',
33
+ textColor: 'secondary-color',
34
+ };
@@ -1,4 +1,35 @@
1
+ /* this.GUI/src/stories/Molecules/ComparisonTable/ComparisonTable.css */
2
+ .comparison-table-container {
3
+ overflow-x: auto;
4
+ margin: 20px 0;
5
+ }
6
+
7
+ .comparison-table {
8
+ width: 100%;
9
+ border-collapse: collapse;
10
+ table-layout: auto;
11
+ border: 1px solid var(--neutral-color);
12
+ }
13
+
14
+ .comparison-table th,
15
+ .comparison-table td {
16
+ padding: 12px;
17
+ text-align: center;
18
+ border: 1px solid;
19
+ font-size: 14px;
20
+ }
21
+
22
+ .comparison-table th {
23
+ background-color: var(--neutral-color, #f9f9f9);
24
+ font-weight: bold;
25
+ }
1
26
 
2
- .comparisontable {
3
- /* Default styles for ComparisonTable */
27
+ .comparison-table .row-header {
28
+ background-color: var(--neutral-color, #f0f0f0);
29
+ font-weight: bold;
4
30
  }
31
+
32
+ .comparison-table .highlight {
33
+ background-color: var(--primary-color, #1F877D);
34
+ color: var(--text-color-inverse, white);
35
+ }
@@ -1,25 +1,104 @@
1
-
2
1
  import React from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import './ComparisonTable.css';
5
4
 
6
- /**
7
- * ComparisonTable component
8
- */
9
- export const ComparisonTable = (props) => {
5
+ export const ComparisonTable = ({
6
+ headers,
7
+ rows,
8
+ rowHeaders,
9
+ highlightColumn,
10
+ headerBgColor,
11
+ rowHeaderBgColor,
12
+ highlightBgColor,
13
+ borderColor,
14
+ }) => {
10
15
  return (
11
- <div className="comparisontable" {...props}>
12
- {/* Component implementation */}
16
+ <div className="comparison-table-container">
17
+ <table className="comparison-table" style={{ borderColor: `var(--${borderColor})` }}>
18
+ <thead>
19
+ <tr>
20
+ <th></th>
21
+ {headers.map((header, index) => (
22
+ <th
23
+ key={index}
24
+ className={highlightColumn === index ? 'highlight' : ''}
25
+ style={{
26
+ backgroundColor: `var(--${headerBgColor})`,
27
+ borderColor: `var(--${borderColor})`,
28
+ }}
29
+ >
30
+ {header}
31
+ </th>
32
+ ))}
33
+ </tr>
34
+ </thead>
35
+ <tbody>
36
+ {rows.map((row, rowIndex) => (
37
+ <tr key={rowIndex}>
38
+ <td
39
+ className="row-header"
40
+ style={{
41
+ backgroundColor: `var(--${rowHeaderBgColor})`,
42
+ borderColor: `var(--${borderColor})`,
43
+ }}
44
+ >
45
+ {rowHeaders[rowIndex]}
46
+ </td>
47
+ {row.map((cell, cellIndex) => (
48
+ <td
49
+ key={cellIndex}
50
+ className={highlightColumn === cellIndex ? 'highlight' : ''}
51
+ style={{
52
+ backgroundColor: highlightColumn === cellIndex ? `var(--${highlightBgColor})` : 'inherit',
53
+ borderColor: `var(--${borderColor})`,
54
+ }}
55
+ >
56
+ {cell}
57
+ </td>
58
+ ))}
59
+ </tr>
60
+ ))}
61
+ </tbody>
62
+ </table>
13
63
  </div>
14
64
  );
15
65
  };
16
66
 
17
67
  ComparisonTable.propTypes = {
18
- // Define prop types here
68
+ headers: PropTypes.arrayOf(PropTypes.string).isRequired,
69
+ rows: PropTypes.arrayOf(PropTypes.array).isRequired,
70
+ rowHeaders: PropTypes.arrayOf(PropTypes.string).isRequired,
71
+ highlightColumn: PropTypes.number,
72
+ headerBgColor: PropTypes.oneOf([
73
+ 'primary-color', 'secondary-color', 'info-color', 'warning-color', 'alert-color', 'success-color', 'neutral-color', 'dark-color',
74
+ 'classy-color-1', 'classy-color-2', 'classy-color-3', 'classy-color-4', 'classy-color-5',
75
+ 'small-switch-color-1', 'small-switch-color-2', 'natural-color-1', 'natural-color-2', 'natural-color-3',
76
+ 'grey-friend-1', 'grey-friend-2', 'shade-1', 'shade-2', 'shade-3', 'shade-4',
77
+ ]),
78
+ rowHeaderBgColor: PropTypes.oneOf([
79
+ 'primary-color', 'secondary-color', 'info-color', 'warning-color', 'alert-color', 'success-color', 'neutral-color', 'dark-color',
80
+ 'classy-color-1', 'classy-color-2', 'classy-color-3', 'classy-color-4', 'classy-color-5',
81
+ 'small-switch-color-1', 'small-switch-color-2', 'natural-color-1', 'natural-color-2', 'natural-color-3',
82
+ 'grey-friend-1', 'grey-friend-2', 'shade-1', 'shade-2', 'shade-3', 'shade-4',
83
+ ]),
84
+ highlightBgColor: PropTypes.oneOf([
85
+ 'primary-color', 'secondary-color', 'info-color', 'warning-color', 'alert-color', 'success-color', 'neutral-color', 'dark-color',
86
+ 'classy-color-1', 'classy-color-2', 'classy-color-3', 'classy-color-4', 'classy-color-5',
87
+ 'small-switch-color-1', 'small-switch-color-2', 'natural-color-1', 'natural-color-2', 'natural-color-3',
88
+ 'grey-friend-1', 'grey-friend-2', 'shade-1', 'shade-2', 'shade-3', 'shade-4',
89
+ ]),
90
+ borderColor: PropTypes.oneOf([
91
+ 'primary-color', 'secondary-color', 'info-color', 'warning-color', 'alert-color', 'success-color', 'neutral-color', 'dark-color',
92
+ 'classy-color-1', 'classy-color-2', 'classy-color-3', 'classy-color-4', 'classy-color-5',
93
+ 'small-switch-color-1', 'small-switch-color-2', 'natural-color-1', 'natural-color-2', 'natural-color-3',
94
+ 'grey-friend-1', 'grey-friend-2', 'shade-1', 'shade-2', 'shade-3', 'shade-4',
95
+ ]),
19
96
  };
20
97
 
21
98
  ComparisonTable.defaultProps = {
22
- // Define default props here
23
- };
24
-
25
- export default ComparisonTable;
99
+ highlightColumn: null,
100
+ headerBgColor: 'neutral-color',
101
+ rowHeaderBgColor: 'neutral-color',
102
+ highlightBgColor: 'primary-color',
103
+ borderColor: 'neutral-color',
104
+ };
@@ -1,20 +1,81 @@
1
-
1
+ import React from 'react';
2
2
  import { ComparisonTable } from './ComparisonTable';
3
3
 
4
- // Storybook configuration for ComparisonTable component
5
4
  export default {
6
- title: 'Molecules/Tables/ComparisonTable',
5
+ title: 'Molecules/Data/ComparisonTable',
7
6
  component: ComparisonTable,
8
- parameters: {
9
- layout: 'centered',
10
- },
11
7
  argTypes: {
12
- // Define argTypes here
8
+ headerBgColor: {
9
+ control: {
10
+ type: 'select',
11
+ options: [
12
+ 'primary-color', 'secondary-color', 'info-color', 'warning-color', 'alert-color', 'success-color', 'neutral-color', 'dark-color',
13
+ 'classy-color-1', 'classy-color-2', 'classy-color-3', 'classy-color-4', 'classy-color-5',
14
+ 'small-switch-color-1', 'small-switch-color-2', 'natural-color-1', 'natural-color-2', 'natural-color-3',
15
+ 'grey-friend-1', 'grey-friend-2', 'shade-1', 'shade-2', 'shade-3', 'shade-4'
16
+ ],
17
+ },
18
+ },
19
+ rowHeaderBgColor: {
20
+ control: {
21
+ type: 'select',
22
+ options: [
23
+ 'primary-color', 'secondary-color', 'info-color', 'warning-color', 'alert-color', 'success-color', 'neutral-color', 'dark-color',
24
+ 'classy-color-1', 'classy-color-2', 'classy-color-3', 'classy-color-4', 'classy-color-5',
25
+ 'small-switch-color-1', 'small-switch-color-2', 'natural-color-1', 'natural-color-2', 'natural-color-3',
26
+ 'grey-friend-1', 'grey-friend-2', 'shade-1', 'shade-2', 'shade-3', 'shade-4'
27
+ ],
28
+ },
29
+ },
30
+ highlightBgColor: {
31
+ control: {
32
+ type: 'select',
33
+ options: [
34
+ 'primary-color', 'secondary-color', 'info-color', 'warning-color', 'alert-color', 'success-color', 'neutral-color', 'dark-color',
35
+ 'classy-color-1', 'classy-color-2', 'classy-color-3', 'classy-color-4', 'classy-color-5',
36
+ 'small-switch-color-1', 'small-switch-color-2', 'natural-color-1', 'natural-color-2', 'natural-color-3',
37
+ 'grey-friend-1', 'grey-friend-2', 'shade-1', 'shade-2', 'shade-3', 'shade-4'
38
+ ],
39
+ },
40
+ },
41
+ borderColor: {
42
+ control: {
43
+ type: 'select',
44
+ options: [
45
+ 'primary-color', 'secondary-color', 'info-color', 'warning-color', 'alert-color', 'success-color', 'neutral-color', 'dark-color',
46
+ 'classy-color-1', 'classy-color-2', 'classy-color-3', 'classy-color-4', 'classy-color-5',
47
+ 'small-switch-color-1', 'small-switch-color-2', 'natural-color-1', 'natural-color-2', 'natural-color-3',
48
+ 'grey-friend-1', 'grey-friend-2', 'shade-1', 'shade-2', 'shade-3', 'shade-4'
49
+ ],
50
+ },
51
+ },
13
52
  },
14
53
  };
15
54
 
16
- export const Default = {
17
- args: {
18
- // Define default args here
19
- },
20
- };
55
+ const headers = ['Feature', 'Product A', 'Product B', 'Product C'];
56
+ const rowHeaders = ['Price', 'Quality', 'Support', 'Features'];
57
+ const rows = [
58
+ ['$10', '$15', '$20'],
59
+ ['High', 'Medium', 'Low'],
60
+ ['24/7', 'Business Hours', 'Email Only'],
61
+ ['Basic', 'Advanced', 'Premium'],
62
+ ];
63
+
64
+ export const DefaultTable = (args) => (
65
+ <ComparisonTable
66
+ {...args}
67
+ headers={headers}
68
+ rows={rows}
69
+ rowHeaders={rowHeaders}
70
+ />
71
+ );
72
+
73
+ export const HighlightedColumn = (args) => (
74
+ <ComparisonTable
75
+ {...args}
76
+ headers={headers}
77
+ rows={rows}
78
+ rowHeaders={rowHeaders}
79
+ highlightColumn={1}
80
+ />
81
+ );
@@ -0,0 +1,192 @@
1
+ /* Base Styles */
2
+ .dropdown {
3
+ position: relative;
4
+ display: inline-block;
5
+ width: 100%;
6
+ }
7
+
8
+ .dropdown__toggle {
9
+ width: 100%;
10
+ padding: 12px;
11
+ text-align: left;
12
+ border-radius: var(--border-radius);
13
+ background-color: transparent; /* No background for toggle */
14
+ border: 2px solid var(--primary-color); /* Default to primary color */
15
+ color: var(--primary-color); /* Default text color */
16
+ cursor: pointer;
17
+ display: flex;
18
+ justify-content: space-between;
19
+ align-items: center;
20
+ transition: border-color var(--transition-speed), color var(--transition-speed);
21
+ }
22
+
23
+ .dropdown__icon {
24
+ margin-left: 8px;
25
+ font-size: 16px;
26
+ }
27
+
28
+ .dropdown__menu {
29
+ position: absolute;
30
+ top: 100%;
31
+ left: 0;
32
+ width: 100%;
33
+ background-color: var(--background-color);
34
+ border: 1px solid var(--border-color);
35
+ border-radius: var(--border-radius);
36
+ max-height: 200px;
37
+ overflow-y: auto;
38
+ z-index: var(--z-index-tooltip);
39
+ box-shadow: var(--box-shadow);
40
+ }
41
+
42
+ .dropdown__search {
43
+ width: 100%;
44
+ padding: 10px;
45
+ border: none;
46
+ border-bottom: 1px solid var(--border-color);
47
+ outline: none;
48
+ }
49
+
50
+ .dropdown__list {
51
+ list-style: none;
52
+ padding: 0;
53
+ margin: 0;
54
+ }
55
+
56
+ .dropdown__item {
57
+ padding: 10px;
58
+ cursor: pointer;
59
+ transition: background-color var(--transition-speed);
60
+ }
61
+
62
+ /* Item hover effect */
63
+ .dropdown__item:hover {
64
+ background-color: var(--primary-color-hover);
65
+ color: var(--text-color-inverse);
66
+ }
67
+
68
+ /* Color Variants for Border and Text */
69
+ .dropdown--primary-color .dropdown__toggle {
70
+ border-color: var(--primary-color);
71
+ color: var(--primary-color);
72
+ }
73
+
74
+ .dropdown--secondary-color .dropdown__toggle {
75
+ border-color: var(--secondary-color);
76
+ color: var(--secondary-color);
77
+ }
78
+
79
+ .dropdown--info-color .dropdown__toggle {
80
+ border-color: var(--info-color);
81
+ color: var(--info-color);
82
+ }
83
+
84
+ .dropdown--warning-color .dropdown__toggle {
85
+ border-color: var(--warning-color);
86
+ color: var(--warning-color);
87
+ }
88
+
89
+ .dropdown--alert-color .dropdown__toggle {
90
+ border-color: var(--alert-color);
91
+ color: var(--alert-color);
92
+ }
93
+
94
+ .dropdown--success-color .dropdown__toggle {
95
+ border-color: var(--success-color);
96
+ color: var(--success-color);
97
+ }
98
+
99
+ .dropdown--neutral-color .dropdown__toggle {
100
+ border-color: var(--neutral-color);
101
+ color: var(--neutral-color);
102
+ }
103
+
104
+ .dropdown--dark-color .dropdown__toggle {
105
+ border-color: var(--dark-color);
106
+ color: var(--dark-color);
107
+ }
108
+
109
+ /* Classy Palette */
110
+ .dropdown--classy-color-1 .dropdown__toggle {
111
+ border-color: var(--classy-color-1);
112
+ color: var(--classy-color-1);
113
+ }
114
+
115
+ .dropdown--classy-color-2 .dropdown__toggle {
116
+ border-color: var(--classy-color-2);
117
+ color: var(--classy-color-2);
118
+ }
119
+
120
+ .dropdown--classy-color-3 .dropdown__toggle {
121
+ border-color: var(--classy-color-3);
122
+ color: var(--classy-color-3);
123
+ }
124
+
125
+ .dropdown--classy-color-4 .dropdown__toggle {
126
+ border-color: var(--classy-color-4);
127
+ color: var(--classy-color-4);
128
+ }
129
+
130
+ .dropdown--classy-color-5 .dropdown__toggle {
131
+ border-color: var(--classy-color-5);
132
+ color: var (--classy-color-5);
133
+ }
134
+
135
+ /* Small Switch Palette */
136
+ .dropdown--small-switch-color-1 .dropdown__toggle {
137
+ border-color: var(--small-switch-color-1);
138
+ color: var(--small-switch-color-1);
139
+ }
140
+
141
+ .dropdown--small-switch-color-2 .dropdown__toggle {
142
+ border-color: var(--small-switch-color-2);
143
+ color: var(--small-switch-color-2);
144
+ }
145
+
146
+ /* Natural Palette */
147
+ .dropdown--natural-color-1 .dropdown__toggle {
148
+ border-color: var(--natural-color-1);
149
+ color: var(--natural-color-1);
150
+ }
151
+
152
+ .dropdown--natural-color-2 .dropdown__toggle {
153
+ border-color: var(--natural-color-2);
154
+ color: var(--natural-color-2);
155
+ }
156
+
157
+ .dropdown--natural-color-3 .dropdown__toggle {
158
+ border-color: var(--natural-color-3);
159
+ color: var(--natural-color-3);
160
+ }
161
+
162
+ /* Grey Friends */
163
+ .dropdown--grey-friend-1 .dropdown__toggle {
164
+ border-color: var(--grey-friend-1);
165
+ color: var(--grey-friend-1);
166
+ }
167
+
168
+ .dropdown--grey-friend-2 .dropdown__toggle {
169
+ border-color: var(--grey-friend-2);
170
+ color: var(--grey-friend-2);
171
+ }
172
+
173
+ /* Shades */
174
+ .dropdown--shade-1 .dropdown__toggle {
175
+ border-color: var(--shade-1);
176
+ color: var(--shade-1);
177
+ }
178
+
179
+ .dropdown--shade-2 .dropdown__toggle {
180
+ border-color: var(--shade-2);
181
+ color: var(--shade-2);
182
+ }
183
+
184
+ .dropdown--shade-3 .dropdown__toggle {
185
+ border-color: var(--shade-3);
186
+ color: var(--shade-3);
187
+ }
188
+
189
+ .dropdown--shade-4 .dropdown__toggle {
190
+ border-color: var(--shade-4);
191
+ color: var(--shade-4);
192
+ }
@@ -0,0 +1,96 @@
1
+ import React, { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import './Dropdown.css';
4
+
5
+ export const Dropdown = ({
6
+ options,
7
+ placeholder,
8
+ color,
9
+ variant,
10
+ searchable,
11
+ onSelect,
12
+ showArrow,
13
+ }) => {
14
+ const [isOpen, setIsOpen] = useState(false);
15
+ const [searchValue, setSearchValue] = useState('');
16
+ const [filteredOptions, setFilteredOptions] = useState(options);
17
+
18
+ const handleToggle = () => setIsOpen(!isOpen);
19
+
20
+ const handleSearch = (e) => {
21
+ const value = e.target.value;
22
+ setSearchValue(value);
23
+ setFilteredOptions(
24
+ options.filter(option =>
25
+ option.toLowerCase().includes(value.toLowerCase())
26
+ )
27
+ );
28
+ };
29
+
30
+ const handleSelect = (option) => {
31
+ setIsOpen(false);
32
+ setSearchValue('');
33
+ onSelect(option);
34
+ };
35
+
36
+ return (
37
+ <div className={`dropdown dropdown--${variant} dropdown--${color}`}>
38
+ <button
39
+ className="dropdown__toggle"
40
+ onClick={handleToggle}
41
+ aria-expanded={isOpen}
42
+ >
43
+ {searchValue || placeholder}
44
+ {showArrow && <span className="dropdown__icon">&#9662;</span>}
45
+ </button>
46
+
47
+ {isOpen && (
48
+ <div className="dropdown__menu">
49
+ {searchable && (
50
+ <input
51
+ type="text"
52
+ className="dropdown__search"
53
+ value={searchValue}
54
+ onChange={handleSearch}
55
+ placeholder="Search..."
56
+ />
57
+ )}
58
+ <ul className="dropdown__list">
59
+ {filteredOptions.map((option, index) => (
60
+ <li
61
+ key={index}
62
+ className="dropdown__item"
63
+ onClick={() => handleSelect(option)}
64
+ >
65
+ {option}
66
+ </li>
67
+ ))}
68
+ </ul>
69
+ </div>
70
+ )}
71
+ </div>
72
+ );
73
+ };
74
+
75
+ Dropdown.propTypes = {
76
+ options: PropTypes.arrayOf(PropTypes.string).isRequired,
77
+ placeholder: PropTypes.string,
78
+ color: PropTypes.oneOf([
79
+ 'primary', 'secondary', 'info', 'warning', 'alert', 'success', 'neutral', 'dark',
80
+ 'classy-color-1', 'classy-color-2', 'classy-color-3', 'classy-color-4', 'classy-color-5',
81
+ 'small-switch-color-1', 'small-switch-color-2', 'natural-color-1', 'natural-color-2', 'natural-color-3',
82
+ 'grey-friend-1', 'grey-friend-2', 'shade-1', 'shade-2', 'shade-3', 'shade-4',
83
+ ]),
84
+ variant: PropTypes.oneOf(['primary', 'secondary']),
85
+ searchable: PropTypes.bool,
86
+ onSelect: PropTypes.func.isRequired,
87
+ showArrow: PropTypes.bool,
88
+ };
89
+
90
+ Dropdown.defaultProps = {
91
+ placeholder: 'Select an option',
92
+ color: 'primary',
93
+ variant: 'primary',
94
+ searchable: false,
95
+ showArrow: true,
96
+ };