From 0673a1a7f4ae40eb081df5665dbf9b9d96f7c835 Mon Sep 17 00:00:00 2001 From: vishtree Date: Fri, 9 Apr 2021 10:18:04 +0200 Subject: [PATCH 1/2] fixed propType for NewActivitiesNotification component --- src/components/NewActivitiesNotification.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/NewActivitiesNotification.js b/src/components/NewActivitiesNotification.js index 256de2f4..dc206075 100644 --- a/src/components/NewActivitiesNotification.js +++ b/src/components/NewActivitiesNotification.js @@ -78,7 +78,7 @@ class NewActivitiesNotification extends React.Component { NewActivitiesNotification.propTypes = { adds: PropTypes.arrayOf(PropTypes.object), - deletes: PropTypes.arrayOf(PropTypes.object), + deletes: PropTypes.arrayOf(PropTypes.string), labelSingular: PropTypes.string, labelPlural: PropTypes.string, /** From b5e508063dfa0722eac97f71a8c205f3f5f1090f Mon Sep 17 00:00:00 2001 From: vishtree Date: Fri, 9 Apr 2021 12:32:45 +0200 Subject: [PATCH 2/2] fixing theming logic --- src/components/BackButton.js | 2 +- src/components/StatusUpdateForm.js | 5 +---- src/styles.js | 36 ++++++++++-------------------- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/src/components/BackButton.js b/src/components/BackButton.js index d5f3021b..df2f060a 100644 --- a/src/components/BackButton.js +++ b/src/components/BackButton.js @@ -21,7 +21,7 @@ export default class BackButton extends React.Component { const { blue, pressed } = this.props; return ( - + )} diff --git a/src/styles.js b/src/styles.js index a594319d..499d909f 100644 --- a/src/styles.js +++ b/src/styles.js @@ -20,7 +20,7 @@ export const styles = { }, }), backButton: StyleSheet.create({ - backButton: { + container: { width: 50, paddingRight: 6, paddingTop: 6, @@ -445,20 +445,6 @@ export const styles = { }), }; -const depthOf = function(object) { - let level = 1; - let key; - for (key in object) { - if (!object.hasOwnProperty(key)) continue; - - if (typeof object[key] == 'object') { - const depth = depthOf(object[key]) + 1; - level = Math.max(depth, level); - } - } - return level; -}; - export function getStyle(styleName) { return styles[styleName] || {}; } @@ -472,21 +458,23 @@ export function buildStylesheet(styleName, styleOverwrites) { if (!styleOverwrites || Object.keys(styleOverwrites).length === 0) { return baseStyle; } - const falseObj = {}; + const base = Object.keys(baseStyle) .map((k) => ({ [k]: StyleSheet.flatten(baseStyle[k]) })) .reduce((accumulated, v) => Object.assign(accumulated, v), {}); + const styleKeysExceptStyleName = Object.keys(styles).filter( + (k) => k !== styleName, + ); const topLevelOverwrites = Object.keys(styleOverwrites) - .map((k) => { - if (depthOf(styleOverwrites[k]) === 1) { - return { [k]: StyleSheet.flatten(styleOverwrites[k]) }; - } - return falseObj; - }) - .filter((v) => v !== falseObj) + /** + * Exclude styling around child components. For example, when you provide styles for + * urlPreview as part of styles for StatusUpdateForm. They will be handled separately + * in UrlPreview component. + */ + .filter((k) => !styleKeysExceptStyleName.includes(k)) + .map((k) => ({ [k]: StyleSheet.flatten(styleOverwrites[k]) })) .reduce((accumulated, v) => Object.assign(accumulated, v), {}); - // console.log(_.defaultsDeep(topLevelOverwrites, base)); return StyleSheet.create(_.defaultsDeep(topLevelOverwrites, base)); }