Ionic + React onboarding UI
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

281 lines
11 KiB

  1. import { IonContent, IonRange, IonButton, IonSlides, IonSlide, IonIcon } from '@ionic/react';
  2. import React, { useState, useRef } from 'react';
  3. import styles from './AdditionalQuestions.module.scss';
  4. const slideOpts = {
  5. initialSlide: 0,
  6. speed: 400,
  7. followFinger: false,
  8. draggable: false,
  9. longSwipes: false,
  10. noSwiping: true,
  11. };
  12. const jobSectors = [{
  13. value: 1,
  14. icon: 'assets/images/signup/categories/laptop.svg',
  15. text: 'Information Technology',
  16. }, {
  17. value: 2,
  18. icon: 'assets/images/signup/categories/medical-cross.svg',
  19. text: 'Health Care'
  20. }, {
  21. value: 3,
  22. icon: 'assets/images/signup/categories/money.svg',
  23. text: 'Finance'
  24. }, {
  25. value: 4,
  26. icon: 'assets/images/signup/categories/headset.svg',
  27. text: 'Communication Services'
  28. }, {
  29. value: 5,
  30. icon: 'assets/images/signup/categories/industry.svg',
  31. text: 'Industrials'
  32. }, {
  33. value: 6,
  34. icon: 'assets/images/signup/categories/line-chart-line.svg',
  35. text: 'Consumer Staples'
  36. }, {
  37. value: 7,
  38. icon: 'assets/images/signup/categories/night-lightning.svg',
  39. text: 'Energy'
  40. }, {
  41. value: 8,
  42. icon: 'assets/images/signup/categories/cog-outline.svg',
  43. text: 'Utilities'
  44. }, {
  45. value: 9,
  46. icon: 'assets/images/signup/categories/sprout.svg',
  47. text: 'Real Estate'
  48. }, {
  49. value: 10,
  50. icon: 'assets/images/signup/categories/pattern.svg',
  51. text: 'Others'
  52. }];
  53. const pluginModules = [{
  54. value: 1,
  55. icon: 'assets/images/signup/modules/tasks-line.svg',
  56. text: 'Task'
  57. }, {
  58. value: 2,
  59. icon: 'assets/images/signup/modules/briefcase-outline.svg',
  60. text: 'Client'
  61. }, {
  62. value: 3,
  63. icon: 'assets/images/signup/modules/bxs-user-badge.svg',
  64. text: 'Employee'
  65. }, {
  66. value: 4,
  67. icon: 'assets/images/signup/modules/pen.svg',
  68. text: 'Training'
  69. }, {
  70. value: 5,
  71. icon: 'assets/images/signup/modules/money.svg',
  72. text: 'Financial'
  73. }, {
  74. value: 6,
  75. icon: 'assets/images/signup/modules/chat-bubble.svg',
  76. text: 'Chat'
  77. }, {
  78. value: 7,
  79. icon: 'assets/images/signup/modules/tennisball-outline.svg',
  80. text: 'Recreation'
  81. }, {
  82. value: 8,
  83. icon: 'assets/images/signup/modules/mail-outline.svg',
  84. text: 'Email'
  85. }, {
  86. value: 9,
  87. icon: 'assets/images/signup/modules/lock.svg',
  88. text: 'Password'
  89. }];
  90. const profileImages = [
  91. 'assets/images/signup/profile-pictures/avatar1.svg',
  92. 'assets/images/signup/profile-pictures/avatar2.svg',
  93. 'assets/images/signup/profile-pictures/avatar3.svg',
  94. 'assets/images/signup/profile-pictures/avatar4.svg',
  95. 'assets/images/signup/profile-pictures/avatar5.svg',
  96. 'assets/images/signup/profile-pictures/avatar6.svg',
  97. 'assets/images/signup/profile-pictures/avatar7.svg',
  98. 'assets/images/signup/profile-pictures/avatar8.svg',
  99. 'assets/images/signup/profile-pictures/avatar9.svg',
  100. 'assets/images/signup/profile-pictures/avatar10.svg',
  101. 'assets/images/signup/profile-pictures/avatar11.svg',
  102. 'assets/images/signup/profile-pictures/avatar12.svg',
  103. 'assets/images/signup/profile-pictures/avatar13.svg'
  104. ]
  105. const AdditionalQuestions: React.FC = () => {
  106. let [index, setIndex] = useState(0),
  107. [userType, changeUserType] = useState('INDIVIDUAL'),
  108. [userSector, changeUserSector] = useState(jobSectors[0]),
  109. [showPicker, toggleShowPicker] = useState(false),
  110. [totalSlides, setSlideCount] = useState(0),
  111. [teamSize, setTeamSize] = useState({
  112. start: 1,
  113. end: 10
  114. }),
  115. [selectedModules, setModules] = useState([pluginModules[0].value]),
  116. [selectedImage, setProfileImage] = useState(profileImages[0]);
  117. const additionalSlides: any = useRef(null);
  118. const getDigitPadding = (digit: number) => {
  119. return digit.toString().padStart(2, '0');
  120. }
  121. const changeIndex = async (event: any) => {
  122. await event.target.getActiveIndex().then((index: number) => setIndex(index = index));
  123. await event.target.length().then((length: number) => { setSlideCount(totalSlides = length) });
  124. }
  125. const nextSlide = async () => {
  126. const swiper: any = await additionalSlides.current?.getSwiper();
  127. swiper.slideNext();
  128. }
  129. const prevSlide = async () => {
  130. const swiper: any = await additionalSlides.current?.getSwiper();
  131. swiper.slidePrev();
  132. }
  133. const toggleModule = (value: number) => {
  134. let tempModules = selectedModules;
  135. if (tempModules.includes(value)) {
  136. tempModules.splice(tempModules.indexOf(value), 1);
  137. } else {
  138. tempModules.push(value);
  139. }
  140. setModules(selectedModules);
  141. }
  142. return (<IonContent fullscreen>
  143. <header className={styles.slidersNavBar}>
  144. <h4>
  145. { getDigitPadding(index + 1)}<span>/{ getDigitPadding(totalSlides) } </span>
  146. </h4>
  147. <IonButton> Skip <IonIcon src='assets/images/signup/skip.svg'></IonIcon> </IonButton>
  148. </header>
  149. <IonSlides options={slideOpts}
  150. className={styles.slides}
  151. ref={additionalSlides} onIonSlideDidChange={(e) => changeIndex(e)}
  152. onIonSlidesDidLoad={(e) => changeIndex(e)}>
  153. <IonSlide>
  154. <div className={styles.questionContainer}>
  155. <p className={styles.question}> Select if you represent a <strong> company </strong> or if you're an <strong> individual </strong> </p>
  156. <p className={styles.hint}> Select answer below </p>
  157. </div>
  158. <div className={styles.choiceContainer}>
  159. <div className={styles.optionButtons}>
  160. <button className={ userType === 'COMPANY' ? styles.active : '' }
  161. onClick={() => changeUserType(userType = 'COMPANY')}> <IonIcon className={styles.leftIcon} src='assets/images/signup/building.svg'></IonIcon> Company <IonIcon className={styles.checkmark} src='assets/images/signup/checkmark.svg'></IonIcon> </button>
  162. <button className={ userType === 'INDIVIDUAL' ? styles.active : '' }
  163. onClick={() => changeUserType(userType = 'INDIVIDUAL')}> <IonIcon className={styles.leftIcon} src='assets/images/signup/user.svg'></IonIcon> Individual <IonIcon className={styles.checkmark} src='assets/images/signup/checkmark.svg'></IonIcon> </button>
  164. </div>
  165. </div>
  166. </IonSlide>
  167. <IonSlide>
  168. <div className={styles.questionContainer}>
  169. <p className={styles.question}> Which <strong> sector </strong>
  170. { userType === 'COMPANY' && <span> does your company below to? </span> }
  171. { userType === 'INDIVIDUAL' && <span> do you work under? </span> } </p>
  172. <p className={styles.hint}> Select answer below </p>
  173. </div>
  174. <div className={styles.choiceContainer}>
  175. <div className={styles.optionButtons}>
  176. <button className={styles.optionButton} onClick={ () => toggleShowPicker( showPicker = true )}> { userSector ? <span> <IonIcon className={styles.sectorIcon} src={ userSector.icon }></IonIcon> { userSector.text } </span> : <span> Select an Option </span> } <IonIcon className={styles.option} src='assets/images/signup/options.svg'></IonIcon> </button>
  177. </div>
  178. </div>
  179. </IonSlide>
  180. <IonSlide>
  181. <div className={styles.questionContainer}>
  182. <p className={styles.question}> What is your working <strong> team size? </strong> </p>
  183. <p className={styles.hint}> Select answer below </p>
  184. </div>
  185. <div className={styles.choiceContainer}>
  186. <p>
  187. { teamSize.end > 9 && <span> { getDigitPadding(teamSize.start) } to </span> } { getDigitPadding(teamSize.end) }
  188. </p>
  189. <IonRange onIonChange={ (e: any) => setTeamSize({
  190. start: (e.detail.value === 10 ? 1: e.detail.value - 10),
  191. end: e.detail.value
  192. }) } mode={'ios'} value={teamSize.end} min={10} max={100} step={10} snaps={true} />
  193. </div>
  194. </IonSlide>
  195. <IonSlide>
  196. <div className={styles.questionContainer}>
  197. <p className={styles.question}> Select the <strong> modules </strong> that you would like to use. </p>
  198. <p className={styles.hint}> Select answer below </p>
  199. </div>
  200. <div className={styles.choiceContainer}>
  201. <ul className={styles.modules}>
  202. { pluginModules.map((module) => {
  203. return <li key={module.value}>
  204. <button className={selectedModules.includes(module.value) ? styles.active : ''}
  205. onClick={() => toggleModule(module.value)}>
  206. <IonIcon src={module.icon}></IonIcon> <label> { module.text } </label>
  207. </button>
  208. </li>
  209. }) }
  210. </ul>
  211. </div>
  212. </IonSlide>
  213. <IonSlide>
  214. <div className={styles.questionContainer}>
  215. <p className={styles.question}> Select a cool <strong> avatar </strong> or upload your ugly <strong> photo </strong> for <strong> profile picture </strong> </p>
  216. <p className={styles.hint}> Select answer below </p>
  217. </div>
  218. <div className={styles.choiceContainer}>
  219. <ul className={styles.profileImages}>
  220. { profileImages.map((image) => {
  221. return <li key={image}>
  222. <button className={selectedImage === image ? styles.active : ''}>
  223. <IonIcon src={image}></IonIcon>
  224. </button>
  225. </li>
  226. }) }
  227. </ul>
  228. </div>
  229. </IonSlide>
  230. </IonSlides>
  231. <IonButton className={styles.prevButton + ' ' + ( index <= 0 ? styles.inactive : '' )} fill="outline" onClick={ () => prevSlide() }>
  232. <IonIcon src='assets/images/signup/arrow-next.svg'></IonIcon>
  233. </IonButton>
  234. <IonButton className={styles.nextButton + ' ' + (index >= (totalSlides - 1) ? styles.inactive : '')} onClick={ () => nextSlide() }>
  235. Next <IonIcon src='assets/images/signup/arrow-next.svg'></IonIcon>
  236. </IonButton>
  237. { showPicker && <section className={styles.picker}>
  238. <div className={styles.container}>
  239. <ul>
  240. { jobSectors.map((sector) => <li key={sector.value}
  241. className={userSector === sector ? styles.active : ''}
  242. onClick={() => { toggleShowPicker(showPicker = false); changeUserSector(userSector = sector); } }>
  243. <IonIcon src={sector.icon}></IonIcon> { sector.text }
  244. </li>) }
  245. </ul>
  246. </div>
  247. </section> }
  248. </IonContent>);
  249. };
  250. export default AdditionalQuestions;