freemium-survey-components 0.1.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.
Files changed (57) hide show
  1. package/.eslintrc +24 -0
  2. package/.prettierrc +10 -0
  3. package/.storybook/main.js +59 -0
  4. package/.storybook/manager.js +9 -0
  5. package/.storybook/preview.js +1 -0
  6. package/README.md +3 -0
  7. package/index.ts +3 -0
  8. package/lib/index.cjs.js +1 -0
  9. package/lib/index.esm.js +1 -0
  10. package/lib/types/index.d.ts +3 -0
  11. package/lib/types/src/components/button/index.d.ts +25 -0
  12. package/lib/types/src/components/checkbox/index.d.ts +14 -0
  13. package/lib/types/src/components/index.d.ts +6 -0
  14. package/lib/types/src/components/nps/index.d.ts +23 -0
  15. package/lib/types/src/components/progressbar/index.d.ts +8 -0
  16. package/lib/types/src/components/radio-button/index.d.ts +25 -0
  17. package/lib/types/src/components/text-input/index.d.ts +52 -0
  18. package/lib/types/src/index.d.ts +1 -0
  19. package/lib/types/src/mock.d.ts +215 -0
  20. package/lib/types/src/survey/index.d.ts +4 -0
  21. package/lib/types/src/survey/question.d.ts +3 -0
  22. package/lib/types/src/survey/widget.d.ts +4 -0
  23. package/lib/types/src/utils.d.ts +3 -0
  24. package/package.json +97 -0
  25. package/postcss.config.js +4 -0
  26. package/rollup.config.ts +32 -0
  27. package/src/components/button/button.stories.tsx +23 -0
  28. package/src/components/button/index.tsx +67 -0
  29. package/src/components/button/style.css +41 -0
  30. package/src/components/checkbox/checkbox.stories.tsx +34 -0
  31. package/src/components/checkbox/index.tsx +118 -0
  32. package/src/components/checkbox/style.css +85 -0
  33. package/src/components/index.tsx +6 -0
  34. package/src/components/nps/index.tsx +69 -0
  35. package/src/components/nps/nps.stories.tsx +34 -0
  36. package/src/components/nps/style.css +154 -0
  37. package/src/components/progressbar/index.tsx +21 -0
  38. package/src/components/progressbar/progressbar.stories.tsx +22 -0
  39. package/src/components/progressbar/style.css +14 -0
  40. package/src/components/radio-button/index.tsx +66 -0
  41. package/src/components/radio-button/radio.stories.tsx +26 -0
  42. package/src/components/radio-button/style.css +60 -0
  43. package/src/components/text-input/index.tsx +155 -0
  44. package/src/components/text-input/style.css +102 -0
  45. package/src/components/text-input/text-input.stories.tsx +84 -0
  46. package/src/index.tsx +1 -0
  47. package/src/mock.ts +363 -0
  48. package/src/survey/index.tsx +269 -0
  49. package/src/survey/question.tsx +79 -0
  50. package/src/survey/style.css +58 -0
  51. package/src/survey/survey.stories.tsx +28 -0
  52. package/src/survey/widget.css +46 -0
  53. package/src/survey/widget.tsx +17 -0
  54. package/src/theme/index.css +72 -0
  55. package/src/typings/index.d.ts +1 -0
  56. package/src/utils.tsx +12 -0
  57. package/tsconfig.json +22 -0
@@ -0,0 +1,58 @@
1
+ .question-container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ text-align: center;
5
+ max-width: 700px;
6
+ margin: 0 auto;
7
+ align-items: center;
8
+ background: #ffffff;
9
+ border-radius: 4px;
10
+ transition: transform 400ms ease 0ms, opacity 200ms ease 0ms;
11
+ box-shadow: 0px 2px 16px rgba(18, 52, 77, 0.1);
12
+ margin-bottom: 40px;
13
+ padding: 20px;
14
+ gap: 28px;
15
+ }
16
+ .question-text {
17
+ font-size: 1.1rem;
18
+ line-height: 1.5;
19
+ }
20
+
21
+ .action-buttons {
22
+ display: flex;
23
+ justify-content: space-between;
24
+ width: 100%;
25
+ align-items: center;
26
+ }
27
+ .skip-button {
28
+ cursor: pointer;
29
+ background: transparent;
30
+ border: none;
31
+ min-width: 40px;
32
+ padding: 4px 12px;
33
+ border-radius: 4px;
34
+ }
35
+
36
+ .next-button {
37
+ margin: 0 auto;
38
+ }
39
+ .submit {
40
+ padding-bottom: 40px;
41
+ display: flex;
42
+ justify-content: center;
43
+ }
44
+ .responsive-text-field {
45
+ width: 100%;
46
+ }
47
+ .responsive-text-field .textarea-container {
48
+ display: none;
49
+ }
50
+
51
+ @media (max-width: 550px) {
52
+ .responsive-text-field .input-container {
53
+ display: none;
54
+ }
55
+ .responsive-text-field .textarea-container {
56
+ display: flex;
57
+ }
58
+ }
@@ -0,0 +1,28 @@
1
+ import {
2
+ // boolean,
3
+ // select,
4
+ // text,
5
+ withKnobs,
6
+ } from '@storybook/addon-knobs'
7
+ import {storiesOf} from '@storybook/react'
8
+ import React from 'react'
9
+ import Survey from '.'
10
+ import WidgetSurvey from './widget'
11
+ import mockSurvey from '../mock'
12
+
13
+ const stories = storiesOf('Survey', module)
14
+ stories.addDecorator(withKnobs)
15
+ stories.addDecorator((story) => {
16
+ return <div style={{margin: '50px'}}>{story()}</div>
17
+ })
18
+
19
+ stories.add('Desktop', () => (
20
+ <Survey survey={mockSurvey} onSubmit={(data) => console.log(data)} />
21
+ ))
22
+ stories.add('Widget', () => (
23
+ <div style={{width: '400px', margin: '0 auto'}}>
24
+ <WidgetSurvey>
25
+ <Survey survey={mockSurvey} />
26
+ </WidgetSurvey>
27
+ </div>
28
+ ))
@@ -0,0 +1,46 @@
1
+ .widget-container {
2
+ width: 360px;
3
+ height: 360px;
4
+ border: 1px solid;
5
+ position: relative;
6
+ }
7
+ .widget-container .question-container {
8
+ box-shadow: none;
9
+ margin-bottom: 0;
10
+ }
11
+ .widget-container .widget {
12
+ padding-bottom: 24px !important;
13
+ padding-top: 0px !important;
14
+ }
15
+ .widget-header {
16
+ width: 100%;
17
+ height: 32px;
18
+ background-color: #f5f5f5;
19
+ border-bottom: 1px solid #e5e5e5;
20
+ position: relative;
21
+ }
22
+ .icons {
23
+ position: absolute;
24
+ right: 12px;
25
+ top: 6px;
26
+ }
27
+ .widget-footer {
28
+ border-top: 1px solid #d3d3d3;
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ height: 32px;
33
+ width: 100%;
34
+ font-size: 0.85rem;
35
+ position: absolute;
36
+ bottom: 0;
37
+ }
38
+ .widget-container .checkbox-container {
39
+ padding: 8px 16px;
40
+ }
41
+ .widget-container .radio-container {
42
+ padding: 8px 16px;
43
+ }
44
+ .widget-container .checkbox-group {
45
+ gap: 12px;
46
+ }
@@ -0,0 +1,17 @@
1
+ import React from 'react'
2
+ import './widget.css'
3
+ const WidgetSurvey = ({children}: any) => {
4
+ return (
5
+ <div className="widget-container">
6
+ <div className="widget-header">
7
+ <div className="icons">
8
+ <span>-</span>&nbsp;&nbsp;&nbsp;&nbsp;
9
+ <span>x</span>
10
+ </div>
11
+ </div>
12
+ <div className="widget-body">{children}</div>
13
+ <div className="widget-footer">Powered by Freshsurvey</div>
14
+ </div>
15
+ )
16
+ }
17
+ export default WidgetSurvey
@@ -0,0 +1,72 @@
1
+ *,
2
+ *::before,
3
+ *::after {
4
+ box-sizing: border-box;
5
+ }
6
+ /* 2. Remove default margin for common elements */
7
+ body,
8
+ h1,
9
+ h2,
10
+ h3,
11
+ h4,
12
+ h5,
13
+ h6,
14
+ p,
15
+ figure,
16
+ blockquote,
17
+ ul,
18
+ ol,
19
+ dl,
20
+ dt,
21
+ dd {
22
+ margin: 0;
23
+ }
24
+ /*
25
+ 3. Allow percentage-based heights in the application
26
+ */
27
+ html,
28
+ body {
29
+ height: 100%;
30
+ background-color: #faebd70f;
31
+ }
32
+
33
+ /* 5. Make images easier to work with */
34
+ img,
35
+ picture {
36
+ max-width: 100%;
37
+ display: block;
38
+ }
39
+ /* 6. Inherit fonts for inputs and buttons */
40
+ input,
41
+ button,
42
+ textarea,
43
+ select {
44
+ font: inherit;
45
+ }
46
+ :root {
47
+ --error-highlight-color: #d72d30;
48
+ --focus-box-shadow-color: #ebeff3;
49
+ --input-border-color: #92a2b1;
50
+ }
51
+
52
+ :root {
53
+ --primary-button-color: #d72d30;
54
+ --primary-button-hover-color: #f1171b;
55
+ --brand-color: #d72d30;
56
+ --input-highlight-color: #2c5cc5;
57
+ --input-border-color: #92a2b1;
58
+ --input-hover-border-color: #264966;
59
+ --input-placeholder-color: #92a2b1;
60
+ --border-radius: 4px;
61
+
62
+ --color-milk: #fff;
63
+ --color-elephant-900: #12344d;
64
+ --color-elephant-800: #264966;
65
+ --color-elephant-700: #345c7c;
66
+ --color-elephant-600: #447093;
67
+ --color-smoke-700: #475867;
68
+ --color-smoke-300: #92a2b1;
69
+ --color-smoke-100: #cfd7df;
70
+ --color-smoke-50: #ebeff3;
71
+ --color-smoke-25: #f3f5f7;
72
+ }
@@ -0,0 +1 @@
1
+ export {}
package/src/utils.tsx ADDED
@@ -0,0 +1,12 @@
1
+ import React from 'react'
2
+
3
+ const withDefaults = <P, DP>(
4
+ component: React.ComponentType<P>,
5
+ defaultProps: DP,
6
+ ) => {
7
+ type Props = Partial<DP> & Omit<P, keyof DP>
8
+ component.defaultProps = defaultProps
9
+ return component as React.ComponentType<Props>
10
+ }
11
+
12
+ export {withDefaults}
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "target": "ESNext",
5
+ "lib": ["dom", "dom.iterable", "esnext"],
6
+ "allowJs": false,
7
+ "skipLibCheck": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "declaration": true,
11
+ "declarationDir": "lib/types",
12
+ "esModuleInterop": true,
13
+ "module": "esnext",
14
+ "moduleResolution": "node",
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "jsx": "react",
18
+ "noImplicitAny": false
19
+ },
20
+ "include": ["src/**/*"],
21
+ "exclude": ["src/**/*.stories.tsx"]
22
+ }