From 45f2dbe4fdb17996760829df430b84d02973a499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tangi=20Mend=C3=A8s?= Date: Mon, 2 Oct 2023 12:04:30 +0200 Subject: [PATCH] fix: preset button --- app/src/components/Button2.js | 38 ++++++++++++++++------------------ app/src/scenes/status/index.js | 2 +- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/app/src/components/Button2.js b/app/src/components/Button2.js index 0954923..4c42b42 100644 --- a/app/src/components/Button2.js +++ b/app/src/components/Button2.js @@ -145,28 +145,26 @@ const applyStyles = ({ ...styles.base, }; - const applyIfNeeded = (cumStyles, condition, styleKey) => { - if (eval(condition)) { - cumStyles.button = { ...cumStyles.button, ...styles[styleKey].button }; - cumStyles.container = { - ...cumStyles.container, - ...styles[styleKey].container, - }; - cumStyles.text = { ...cumStyles.text, ...styles[styleKey].text }; - cumStyles.icon = { ...cumStyles.icon, ...styles[styleKey].icon }; - cumStyles.disabled = { - ...cumStyles.disabled, - ...styles[styleKey].disabled, - }; - } + const applyIfNeeded = (cumStyles, styleKey) => { + cumStyles.button = { ...cumStyles.button, ...styles[styleKey].button }; + cumStyles.container = { + ...cumStyles.container, + ...styles[styleKey].container, + }; + cumStyles.text = { ...cumStyles.text, ...styles[styleKey].text }; + cumStyles.icon = { ...cumStyles.icon, ...styles[styleKey].icon }; + cumStyles.disabled = { + ...cumStyles.disabled, + ...styles[styleKey].disabled, + }; }; - applyIfNeeded(appliedStyles, "preset==='primary'", "primary"); - applyIfNeeded(appliedStyles, "preset==='secondary'", "secondary"); - applyIfNeeded(appliedStyles, "type==='outline'", "outline"); - applyIfNeeded(appliedStyles, "type==='clear'", "clear"); - applyIfNeeded(appliedStyles, "size==='small'", "small"); - applyIfNeeded(appliedStyles, "preset==='onboarding2'", "onboarding2"); + preset === "primary" ? applyIfNeeded(appliedStyles, "primary") : null; + preset === "secondary" ? applyIfNeeded(appliedStyles, "secondary") : null; + type === "outline" ? applyIfNeeded(appliedStyles, "outline") : null; + type === "clear" ? applyIfNeeded(appliedStyles, "clear") : null; + size === "small" ? applyIfNeeded(appliedStyles, "small") : null; + preset === "onboarding2" ? applyIfNeeded(appliedStyles, "onboarding2") : null; if (!fill && size === "default" && !square && !circle) appliedStyles.button.minWidth = "70%"; diff --git a/app/src/scenes/status/index.js b/app/src/scenes/status/index.js index 6437d08..237065c 100644 --- a/app/src/scenes/status/index.js +++ b/app/src/scenes/status/index.js @@ -53,7 +53,7 @@ const Status = ({ navigation }) => { } // si jamais fait de survey ? quepaso ? - console.log("✍️ diaryData:", diaryData); + // console.log("✍️ diaryData:", diaryData); if (!diaryData) return; if (computeNewSurveyAvailable(diaryData)) {