Design system.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

129 рядки
4.0 KiB

  1. import {NextPage} from 'next';
  2. import {DefaultLayout} from '@/components/DefaultLayout';
  3. import {Section, Subsection} from '@/components/Section';
  4. import * as Formatted from '@tesseract-design/web-formatted-react';
  5. import {useRef} from 'react';
  6. import {ActionButton} from '@tesseract-design/web-action-react';
  7. const TemporalPage: NextPage = () => {
  8. const phoneNumberRef = useRef<HTMLInputElement>(null);
  9. return (
  10. <DefaultLayout title="Formatted">
  11. <Section title="PhoneNumberInput">
  12. <Subsection title="Default">
  13. <Formatted.PhoneNumberInput
  14. country="PH"
  15. label="Phone"
  16. name="phone"
  17. enhanced
  18. border
  19. onFocus={(e) => { console.log('focus', e.currentTarget)}}
  20. onBlur={(e) => { console.log('blur', e.currentTarget)}}
  21. onChange={(e) => { console.log('change', e.currentTarget.name, e.currentTarget, e.currentTarget.value)}}
  22. />
  23. </Subsection>
  24. <Subsection title="Non-enhanced">
  25. <Formatted.PhoneNumberInput
  26. country="PH"
  27. label="Phone"
  28. name="phone"
  29. border
  30. onFocus={(e) => { console.log('focus', e.currentTarget)}}
  31. onBlur={(e) => { console.log('blur', e.currentTarget)}}
  32. onChange={(e) => { console.log('change', e.currentTarget.name, e.currentTarget, e.currentTarget.value)}}
  33. />
  34. </Subsection>
  35. <Subsection title="With Default Value">
  36. <Formatted.PhoneNumberInput
  37. country="PH"
  38. label="Phone"
  39. name="phone2"
  40. enhanced
  41. border
  42. defaultValue="+639876543210"
  43. />
  44. </Subsection>
  45. <Subsection title="With Ref">
  46. <div className="flex gap-4 flex-wrap">
  47. <div>
  48. <Formatted.PhoneNumberInput
  49. country="PH"
  50. label="Phone"
  51. name="phone3"
  52. enhanced
  53. border
  54. ref={phoneNumberRef}
  55. onChange={(e) => { console.log('change', e.currentTarget.name, e.currentTarget, e.currentTarget.value)}}
  56. />
  57. </div>
  58. <div>
  59. <ActionButton
  60. onClick={() => {
  61. if (phoneNumberRef.current) {
  62. phoneNumberRef.current.value = '+639123456789';
  63. }
  64. }}
  65. >
  66. Set Value
  67. </ActionButton>
  68. </div>
  69. <div>
  70. <ActionButton
  71. onClick={() => {
  72. if (phoneNumberRef.current) {
  73. phoneNumberRef.current.value = '+63465123456';
  74. }
  75. }}
  76. >
  77. Set Other Value
  78. </ActionButton>
  79. </div>
  80. <div>
  81. <ActionButton
  82. onClick={() => {
  83. if (phoneNumberRef.current) {
  84. phoneNumberRef.current.value = '+63288888888';
  85. }
  86. }}
  87. >
  88. Set Yet Other Value
  89. </ActionButton>
  90. </div>
  91. </div>
  92. </Subsection>
  93. </Section>
  94. <Section title="EmailInput">
  95. <Subsection title="Default">
  96. <Formatted.EmailInput
  97. label="Email"
  98. name="email"
  99. border
  100. />
  101. </Subsection>
  102. <Subsection title="With domains">
  103. <Formatted.EmailInput
  104. label="Email"
  105. name="email"
  106. border
  107. variant="alternate"
  108. domains={['gmail.com', 'yahoo.com']}
  109. hint="Only GMail or Yahoo Mail allowed"
  110. length={50}
  111. />
  112. </Subsection>
  113. </Section>
  114. <Section title="UrlInput">
  115. <Subsection title="Default">
  116. <Formatted.UrlInput
  117. label="Website"
  118. name="website"
  119. border
  120. />
  121. </Subsection>
  122. </Section>
  123. </DefaultLayout>
  124. )
  125. }
  126. export default TemporalPage;