-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(text randomizer): implement text randomizer and toggle between wheel #14
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Try Ajitiono <[email protected]>
Signed-off-by: Try Ajitiono <[email protected]>
Signed-off-by: Try Ajitiono <[email protected]>
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/ans4175/random-gofood/9sj5fCsT2sSPyvngsK5H582VQLPM [Deployment for c8b8b9f failed] |
@ans-4175 ada ide ngga untuk ngedengerin event change di tabsnya? Tidak terlihat ada propsnya di docs ini: https://github.com/rough-stuff/wired-elements/blob/master/docs/wired-tabs.md#wiredtabs-properties Terus saya entah kenapa dapet eror ini: padahal di Codesandbox seperti aman: https://codesandbox.io/s/react-wrapper-for-wired-elements-forked-fef11?file=/src/index.js |
Ini kemarin aku kena isu ini di Roulette, bukan di wired element kalau tak salah. |
https://github.com/rough-stuff/wired-elements/blob/master/src/wired-tabs.ts |
OK, ini bisa dicoba |
src/App.js
Outdated
<p>Loading merchants data...</p> | ||
) : isError || posError ? ( | ||
<p>Error: {isError ? error.message : posError.message}</p> | ||
) : ( | ||
<> | ||
<section> | ||
{wheelData && ( | ||
<> | ||
<WiredTabs selected="wheel"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah ini coba dipasang property selected-nya kalau berubah gitu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
o ternyata dia kalau hasil build dengan NODE_ENV=production
ngga eror ya? Cuma di lokal aja erornya... menarik
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error yang selected?
Aku belum nyambung
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iyak, ini kalau di lokal aku, dia bakal ngecrash
tapi kalau di https://random-gofood-git-fork-imballinst-10-tabs-randomizer-ans4175.vercel.app/, dia nggak nge-crash, kenapa yak? padahal kodenya sama
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kalau aku dulu, itu masalah si pas yarn start-nya, kl dijalanin ulang lagi tetap masalah?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ans-4175 saya isi
saya coba nuke terus install ulang |
wah, kurang paham, saya download file Sandbox https://codesandbox.io/s/react-wrapper-for-wired-elements-forked-fef11?file=/src/index.js, install, lalu jalanin, tetep crash 😅 mungkin harus dibawa tidur dulu baru bisa jalan @ans-4175 kalau sempat, boleh tolong coba jalanin PR ini di lokal nggak? atau download lalu jalanin Sandbox ☝️ di lokal? takutnya ada masalah dependency yang aneh-aneh kayak apollographql/apollo-link-state#187 |
Oh, kayaknya ini penyebabnya: rough-stuff/rough@24fd61d#diff-054c66f0fb4838b0ff226ca4dea0ebcc007364ff1baf314d788a8015cbac108a Dia ngeresolve packagenya ke package versi yang terbaru, yang mana EDIT: hore bisa |
Oh oke, fixed? |
@ans-4175 iyak, fixed. Saya submit bugnya di rough-stuff/wired-elements#179. Nanti saya follow-up di sini pakai Yarn module resolutions ke |
Signed-off-by: Try Ajitiono <[email protected]>
@ans-4175 saya boleh pake https://www.npmjs.com/package/patch-package aja nggak? Kayaknya lebih straightforward daripada kalau harus nambahin ref lalu listen childrennya... mungkin kalau mau nanti patchnya bisa dikontribusiin juga ke wired-elements-react
wired-elements
|
Aku belum pernah pakai
Itu gimana ya?
Possible aja ya
On Fri, 19 Nov 2021 at 19.59 Try Ajitiono ***@***.***> wrote:
@ans-4175 <https://github.com/ans-4175> saya boleh pake
https://www.npmjs.com/package/patch-package aja nggak? Kayaknya lebih
straightforward daripada kalau harus nambahin ref lalu listen
childrennya... mungkin kalau mau nanti patchnya bisa dikontribusiin juga ke
wired-elements dan wired-elements-react
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#14 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA6HIEFD3NZ3RQWK42U2LYLUMZCZRANCNFSM5IJ2CPUQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
--
Ahmad Anshorimuslim Syuhada
Data Engineer - Web Developer - Linux Enthusiast
+6285224752182 - @ans4175
"trust me I'm [already] an engineer"
|
@ans-4175 kira-kira bagusan mana? yang pertama atau yang kedua? yang pertama yang bawaan, yang kedua yang saya tweak. kok saya ngerasanya ada "border" di sekitar wheel itu kurang cocok ya? soalnya dia udah di atas elemen wired anyway... apakah elemen wired di atas elemen wired itu design language yang masuk? |
@ans-4175 jadi kita nge-update |
Kita ngunci di paketnya gitu ya terus bikin diff
Boleh deh cobain
Aku ga terlalu kebayang ji
Anyway, iyah tanpa border lebih masuk pas kayaknya
Itu pakai wired card buatnya? Kok aneh ya
On Fri, 19 Nov 2021 at 20.10 Try Ajitiono ***@***.***> wrote:
Aku belum pernah pakai
Itu gimana ya?
Possible aja ya
@ans-4175 <https://github.com/ans-4175> jadi kita nge-update node_modules,
nanti si patch-package ini bakal nge-output diff dari file-file yang kita
update. setiap kali kita pakai command yarn, dia bakal re-apply diff-diff
tersebut, jadi hasilnya konsisten
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#14 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA6HIEE3X4VH5P5CGIZRV3DUMZEETANCNFSM5IJ2CPUQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
--
Ahmad Anshorimuslim Syuhada
Data Engineer - Web Developer - Linux Enthusiast
+6285224752182 - @ans4175
"trust me I'm [already] an engineer"
|
iyak, betul 💯
kayaknya si tabs ini di-desain untuk berada di "tempat kosong" (bukan di atas elemen wired)... soalnya bawaan dari |
Signed-off-by: Try Ajitiono <[email protected]>
Signed-off-by: Try Ajitiono <[email protected]>
Signed-off-by: Try Ajitiono <[email protected]>
+ fireSelected() { | ||
+ fireEvent(this, 'selected', { selected: this.selected }); | ||
+ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ans-4175 begini kurang lebih cara saya nambahin event emitter (?) di komponennya
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, berarti nanti dibacanya di atasnya onselected
sama seperti yang radio group button
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iyak, betul
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ada beberapa logic yang shown merchant detail ini, nampaknya callback react-nya ga pas cycle-nya
@@ -20,7 +20,8 @@ | |||
"build": "CI=false && react-scripts build", | |||
"test": "react-scripts test", | |||
"eject": "react-scripts eject", | |||
"prettify": "prettier --write src" | |||
"prettify": "prettier --write src", | |||
"postinstall": "patch-package" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hoo baru tahu begini, berarti ini auto jalan?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iyak, jadi urutannya:
yarn
--> node_modules
terinstall (raw) --> patch-package
(apply diff dari patches yang ada)
@@ -0,0 +1,113 @@ | |||
diff --git a/node_modules/wired-elements/lib/wired-lib.js b/node_modules/wired-elements/lib/wired-lib.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cara bikinnya ini gimana ji? BIkin file perubahannya, terus di diff sendiri dan hasil diffnya masukkin sini?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming filenya juga?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
o ini ada caranya, maap, habis ini saya tambahin di READMEnya
} | ||
draw(svg, s) { | ||
- rectangle(svg, 2, 2, s[0] - 4, s[1] - 4, this.seed); | ||
+ if (this.hasBorder) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha nice
src/App.js
Outdated
setFetched(false); | ||
setMustSpin(false); | ||
refetch(); | ||
resetStates(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yap nice
<Wheel | ||
mustStartSpinning={mustSpin} | ||
mustStartSpinning={ | ||
randomizerMode === 'wheel' && mustStartRandomizing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh nice
src/App.js
Outdated
<p className="txt-resto text-center">{pickedMerchant.name}</p> | ||
{detailMerchant !== undefined && | ||
pickedMerchant !== undefined && | ||
isMerchantDetailShown && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coba cek logic isMerchantDetailShown
ini keubah dimana ya? Jadi muncul duluan sebelum beres stop spin atau randomizer
<div>{optionsList[0].option}</div> | ||
|
||
<div className="randomizer-text-helper"> | ||
Press "Randomize" button below to start. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wkwk, anti pattern. Dia berharap ada tombol click di bawah di luar dari component ini
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wkwkwk, bener juga sih... apa kalau gitu mending dibuat gini?
- Tombol spin dan tombol reset jadi 1 komponen sendiri:
SpinnerButtons
- Bikin komponen baru:
WheelRandomizer
-- yang ngeimportSpinnerButtons
- Import
SpinnerButtons
diTextBlinkRandomizer
yang ada sekarang - Delete spinner buttons yang ada di
App.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saya jadinya pakai pattern children
, kira-kira gimana? Saya senangnya pattern ini karena kita nggak perlu nambahin prop sih:
// App.js.
const spinnerButtons = mustStartRandomizing ? (
<p>Waiting to {randomizeText}...</p>
) : (
<div>
<WiredButton elevation={2} onClick={handleSpinClick}>
{randomizeText}
</WiredButton>
<WiredButton
className="btn-reset"
elevation={2}
onClick={handleResetClick}
>
RE-LOAD
</WiredButton>
</div>
);
<TextBlinkRandomizer
onFinishRandomizing={onFinishRandomizing}
mustStartRandomizing={
randomizerMode === 'text' && mustStartRandomizing
}
pickedMerchant={pickedMerchant}
optionsList={optionsList}
>
{spinnerButtons}
</TextBlinkRandomizer>
// TextBlinkRandomizer.js.
if (shownText === undefined) {
return (
<>
<div className="randomizer-text-container">
<div>{optionsList[0].option}</div>
<div className="randomizer-text-helper">
Press "Randomize" button below to start.
</div>
</div>
{children}
</>
);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh nice ini, dia berarti selalu dibungkus sesuatu. sip, betul jadi ga ngerubah prop sebelumnya
Signed-off-by: Try Ajitiono <[email protected]>
Signed-off-by: Try Ajitiono <[email protected]>
Gabisa deng, dia classnya itu random generated eh
On Sat, 20 Nov 2021 at 09.16 Try Ajitiono ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/App.css
<#14 (comment)>:
> @@ -11,7 +11,9 @@ wired-card {
}
section {
- max-width: 400px;
+ /* Make this the same with the wheel's width. */
+ /* That way, the wheel will be properly centered. */
+ max-width: 445px;
saya belum riset mendalam, tapi mungkin bisa sih override max-width style
di class bhdLno
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#14 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA6HIEB7QOU4RW4DX2KCF7LUM4AIRANCNFSM5IJ2CPUQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
--
Ahmad Anshorimuslim Syuhada
Data Engineer - Web Developer - Linux Enthusiast
+6285224752182 - @ans4175
"trust me I'm [already] an engineer"
|
Signed-off-by: Try Ajitiono <[email protected]>
Signed-off-by: Try Ajitiono <[email protected]>
oiya deng, dia pakai |
Signed-off-by: Try Ajitiono <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README.md
Outdated
To apply the patches under the [patches](./patches) folder, do this in the root of this project: | ||
|
||
```shell | ||
yarn patch-package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn postinstall
bukan harusnya?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
o bener, yarn postinstall
aja biar ngereference ke scripts
, siap
setDetailMerchant(undefined); | ||
setMustStartRandomizing(true); | ||
// Disable the tabs. | ||
tabsRef.current.requestUpdate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sip
} | ||
}, [merchants]); | ||
|
||
const randomizeText = randomizerMode === 'wheel' ? 'Spin' : 'Randomize'; | ||
const isMerchantDetailShown = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh nice
@@ -0,0 +1,25 @@ | |||
import { Wheel } from 'react-custom-roulette'; | |||
|
|||
export default function WheelRandomizer({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice pattern here
Signed-off-by: Try Ajitiono <[email protected]>
Signed-off-by: Try Ajitiono <[email protected]>
@ans-4175 harusnya sih udah bener, ya... tapi buildnya masih gagal, kenapa ya? 2021-11-21.08-49-45.movsaya pengen nambahin test, tapi ditolak sama |
Closes #10. This PR contains:
TextBlinkRandomizer