From 98ff406ddf444421cc4d018dbf01ca3b87943bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 10 Apr 2022 12:46:25 +0200 Subject: [PATCH] typescript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../components/autosuggest_textarea.js | Bin 8365 -> 8337 bytes .../compose/components/autosuggest_account.js | Bin 551 -> 0 bytes .../components/autosuggest_account.tsx | 21 +++++++ .../compose/components/compose_form.js | Bin 14101 -> 14073 bytes .../components/text_character_counter.js | Bin 684 -> 0 bytes .../components/text_character_counter.tsx | 28 ++++++++++ .../compose/components/upload_form.js | Bin 1052 -> 0 bytes .../compose/components/upload_form.tsx | 33 +++++++++++ .../components/visual_character_counter.js | Bin 1127 -> 0 bytes .../components/visual_character_counter.tsx | 35 ++++++++++++ .../autosuggest_account_container.js | Bin 424 -> 0 bytes .../containers/upload_form_container.js | Bin 274 -> 0 bytes .../compose/util/{counter.js => counter.ts} | Bin 273 -> 281 bytes .../util/{url_regex.js => url_regex.ts} | Bin 15674 -> 15738 bytes .../generic_not_found/{index.js => index.tsx} | Bin .../features/ui/components/accordion.js | Bin 1687 -> 0 bytes .../features/ui/components/accordion.tsx | 52 ++++++++++++++++++ 17 files changed, 169 insertions(+) delete mode 100644 app/soapbox/features/compose/components/autosuggest_account.js create mode 100644 app/soapbox/features/compose/components/autosuggest_account.tsx delete mode 100644 app/soapbox/features/compose/components/text_character_counter.js create mode 100644 app/soapbox/features/compose/components/text_character_counter.tsx delete mode 100644 app/soapbox/features/compose/components/upload_form.js create mode 100644 app/soapbox/features/compose/components/upload_form.tsx delete mode 100644 app/soapbox/features/compose/components/visual_character_counter.js create mode 100644 app/soapbox/features/compose/components/visual_character_counter.tsx delete mode 100644 app/soapbox/features/compose/containers/autosuggest_account_container.js delete mode 100644 app/soapbox/features/compose/containers/upload_form_container.js rename app/soapbox/features/compose/util/{counter.js => counter.ts} (81%) rename app/soapbox/features/compose/util/{url_regex.js => url_regex.ts} (98%) rename app/soapbox/features/generic_not_found/{index.js => index.tsx} (100%) delete mode 100644 app/soapbox/features/ui/components/accordion.js create mode 100644 app/soapbox/features/ui/components/accordion.tsx diff --git a/app/soapbox/components/autosuggest_textarea.js b/app/soapbox/components/autosuggest_textarea.js index 9b5d186f53a0d7b95992e2bb1dcc8b470d5c0322..69ec5d7a1e7a839cfe23620c205697edc5df97cb 100644 GIT binary patch delta 33 pcmZ4MIMH!KFyrJHMp^dUg8aPHypqWcjG~+8Gp2}c<`G}W2>{Bk3r_$5 delta 104 zcmbQ}xYlt)Fr$xieqKppW?pKMLRwLNu7bLro_<qOis=(%`1tAOKKF`7@e8(w{Tmnc*PY zP8)(}qr2Dd4lPthw{YnE{zT)!A&+FxT#yTz@6EX0u6l45U$8+z+Q6_EoeY-l=A{d! z5JEe(fYLMzkI>#lp(2~{pxEPE{*I4GOYP#YR@>QoY&Q~GS%Simwyv(xu4N439%Kna z0_+TZ1Q4Y4MrQEaDo*lMHunW=KW!Xa;)D}% = ({ id }) => { + const getAccount = makeGetAccount(); + const account = useAppSelector((state) => getAccount(state, id)); + + if (!account) return null; + + return ; + +}; + +export default AutosuggestAccount; diff --git a/app/soapbox/features/compose/components/compose_form.js b/app/soapbox/features/compose/components/compose_form.js index 1c17c5ae18b3b96d3a55c3f5ded95cd4bd1f49df..675abe4bf40155702d021cae2e3c3929d7d80033 100644 GIT binary patch delta 53 zcmbQ5_cM3HFD91sSuV1`#Wh&M_Rb#xXMm DsX`G$ diff --git a/app/soapbox/features/compose/components/text_character_counter.js b/app/soapbox/features/compose/components/text_character_counter.js deleted file mode 100644 index 08eec99feb7cd79b0b4d57132be1dec4ed539fc2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 684 zcmZ`$L2iRE5WMq>y+NcvbEtYqLN2*iQIrojun?=*rfVZ5Mf|;Ma0seYE?#EGvomX{ zT0;(sMp*kP6k4drD2PWudm!FLaw46`w3kOab6WmSod;f=Gm63m4f6G?)kA~2b~hM8 z-#U`I{$WOh_t8d)mFSva2QGMb$D1HlK{}dF^8t*ZE-j3MvQtNRG;B|!cF;!=fOW#j z0=&7&Y|c3F=lJRt<`CI5K9ly0-<>2Z*CS1d`;w(Qbw&Ea8rU*Gal_*4j7mt&IlSAX zlvT9~^9Wr>8j?{JU~gNYL(O-e3(xzxv`OqerdB~^G@q#C)ih%H6)-oJU*Q**Ur&ftR+zW`G53|bg% m-Q*$%cat{r%eNVC64LPK$pZHwM=`H7?r3cOx6Uwjh<*Xvx7VNm diff --git a/app/soapbox/features/compose/components/text_character_counter.tsx b/app/soapbox/features/compose/components/text_character_counter.tsx new file mode 100644 index 0000000000..823d24f6f8 --- /dev/null +++ b/app/soapbox/features/compose/components/text_character_counter.tsx @@ -0,0 +1,28 @@ +import classNames from 'classnames'; +import React from 'react'; +import { length } from 'stringz'; + +interface ITextCharacterCounter { + max: number, + text: string, +} + +const TextCharacterCounter: React.FC = ({ text, max }) => { + const checkRemainingText = (diff: number) => { + return ( + = 0, + 'text-danger-600': diff < 0, + })} + > + {diff} + + ); + }; + + const diff = max - length(text); + return checkRemainingText(diff); +}; + +export default TextCharacterCounter; diff --git a/app/soapbox/features/compose/components/upload_form.js b/app/soapbox/features/compose/components/upload_form.js deleted file mode 100644 index 71e89517aa8f93bed12df022d4e1f95070c6da38..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1052 zcmaJ=O>fjd487-9xR++PYBHSL%^s*g>IIFt5m5&X6HvRDRWk`KI zuFy-m7&vcT{;k^4;9bvL9d>6tr}c~}>IKA2G9e)9`+^;5tDo@wXl>u!^_`WvLlY&J zrKpz>30lC1M~^rHkxdy=>dO@ z+Mv4TikbZdFiePMvyDyID6%l6W-vnq_J^j@5z?(^3Lt+)d<)gdfo*cXKEmS2^BfMr z1S)>qrB9gkfD&c-{F;qAW@OLAahWGC6rESs~xMY3C# diff --git a/app/soapbox/features/compose/components/upload_form.tsx b/app/soapbox/features/compose/components/upload_form.tsx new file mode 100644 index 0000000000..4ab98f3a87 --- /dev/null +++ b/app/soapbox/features/compose/components/upload_form.tsx @@ -0,0 +1,33 @@ +import classNames from 'classnames'; +import React from 'react'; + +import { useAppSelector } from 'soapbox/hooks'; + +import type { Attachment as AttachmentEntity } from 'soapbox/types/entities'; + +// import SensitiveButtonContainer from '../containers/sensitive_button_container'; +import UploadProgress from '../components/upload-progress'; +import UploadContainer from '../containers/upload_container'; + +const UploadForm = () => { + const mediaIds = useAppSelector((state) => state.compose.get('media_attachments').map((item: AttachmentEntity) => item.get('id'))); + const classes = classNames('compose-form__uploads-wrapper', { + 'contains-media': mediaIds.size !== 0, + }); + + return ( +
+ + +
+ {mediaIds.map((id: string) => ( + + ))} +
+ + {/* {!mediaIds.isEmpty() && } */} +
+ ); +}; + +export default UploadForm; diff --git a/app/soapbox/features/compose/components/visual_character_counter.js b/app/soapbox/features/compose/components/visual_character_counter.js deleted file mode 100644 index b90ba668df3000918728f89620db76d8fa92b4b0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1127 zcmZuxU9ZzH41Mpf@Y}j+YeBpXijek%1kyACuUA>?ZGko^aViE?|2uZluDw@xnwHi% zw$Jg$bkkbr;plAp?Qe?&7iSw-wfw&GVpzRTbi|xcm43W;@;qPlpv_M#{b%FrEmU~X z2EQVax^l!}>9f-eSvuBeuKxA_k$2i$|1n}p%haxpV;!_BYaC;dRqff{^U^XmgT_;?Kp-4D_7h(s$Gw#l$&UioH|zy?leDs%)29v~Rg$@Qm}IW*A6 zk_;d{q0Hmm!w$mXEp&vyM}vwwhf6opHD`2_8xvwL`3;_`uI(SJ7@sF)t%%@W{&*o;dj{Por;g?;kYt+=rbefac z>Mf6iw1xJIgh7kch^ = ({ text, max }) => { + const intl = useIntl(); + + const textLength = length(text); + const progress = textLength / max; + + return ( + + ); +}; + +export default VisualCharacterCounter; diff --git a/app/soapbox/features/compose/containers/autosuggest_account_container.js b/app/soapbox/features/compose/containers/autosuggest_account_container.js deleted file mode 100644 index f86f01bd97e38c6dfd627c563f557a9bcac49595..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 424 zcmZvY%L>9U5JmU>irJZhkG-XWD_4S`dkN{Z6m6y?6A+~T?xYW^C}er=xi?ccEjflK z7_t@(LkFd!1{Myr;g!Q8JQi7!)Dzd}8y=AN#!#>`zFu#J=kYEYa$ZtnXdjq-s4DdD z*w7&fLn5|l*>CiWUG<=k%`(h0#M+~7&#W0QbaK>s$U&u$@8Fq0oG(;056k<=yi}#) znz-iI6?TU_qo1ji2Qresr>bQ>;M1& diff --git a/app/soapbox/features/compose/util/url_regex.js b/app/soapbox/features/compose/util/url_regex.ts similarity index 98% rename from app/soapbox/features/compose/util/url_regex.js rename to app/soapbox/features/compose/util/url_regex.ts index 4ac11ca05606bb2562af88f9d8488ff4ae65ff26..302519662b08076acd2e5e593ca8b5fdbc12319b 100644 GIT binary patch delta 137 zcmdm0^{YxhIX|zsM4>1(J+&e=&q|?MA-cj!p}3?dGcP?B#!#qH2ue+Ntte2aoye=B zfFZ1-kd~8}UaVlNpsuc|P`xqAl1Uw=NJpV8F{d=O7{lnqyh>|@+Rd|>=34;(F%B1(J+&e=Z=$}AqK-mZPGWkorb0EB0)(kx3#Dsn6x7wNH&$CR Tap)+NCFYc-7H_`IG~WsU&ITE4 diff --git a/app/soapbox/features/generic_not_found/index.js b/app/soapbox/features/generic_not_found/index.tsx similarity index 100% rename from app/soapbox/features/generic_not_found/index.js rename to app/soapbox/features/generic_not_found/index.tsx diff --git a/app/soapbox/features/ui/components/accordion.js b/app/soapbox/features/ui/components/accordion.js deleted file mode 100644 index 6b2b7b2bb70a2832578d2a9f4e0cd5ed15936a0a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1687 zcmaJ>!EW0y487+oxJ&H-j&slAu0y-S4&92Pw_zw0n@O}Ok|)Vo3&a0DO0q3A8`eWm zQ{;Q(dzAR8RoX%=m@!}22@UMEIzi?G(gm{j3m%dlv}&JT+c~GD@0E3dnDdCNwj+ji z|Hq>q8r*Y<_h<||pecaMA6VPZ(h3;TniZ!I6;8x=MAWF?@*ZV3<{8D>oqAc-j`!&+~!9p$}t$hVjHuU38N73xHY)!CHeG=z%vI$XHz~-Ebw#=_o5)A?t)4 zXP~Uxu`Gk3AQXIQnWXB!Fv7vV5I*@5Uq39VS;};lj7)HosN`LNk5gmBW>Gc@MAit>Z3DBbrBn@;+&tp1j%#e(I3&xFi$3!eHI-I)QN$b?kE!o9f1L-`gGb-(<4DCh`D7LU?!r&!yzJ%%;dhhw*u#RNAz|a_h zOFs#1Sc+X-${;?i)T{qE-YK_~C=v%YF8nhk#o=naaZsV02yeI&5y9-B`90sMp*HH2yZq zn$;OK-3KO0b3SCt0UBEL+R`1bGR+T1o54Dz+^$KB7+4PTG}~Qgt&;OMfO`n5EQGTp zKFe37(^+l>rfEvv3SR%LdT&p void, +} + +const Accordion: React.FC = ({ headline, children, menu, expanded = false, onToggle = () => {} }) => { + const intl = useIntl(); + + const handleToggle = (e: React.MouseEvent) => { + onToggle(!expanded); + e.preventDefault(); + }; + + return ( +
+ {menu && ( +
+ +
+ )} + +
+ {children} +
+
+ ); +}; + +export default Accordion;