-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internationalization and configurable options wip
- Loading branch information
Showing
11 changed files
with
717 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* ---------------------------------------------------------- | ||
* Storefront App Default Configurations | ||
* ---------------------------------------------------------- | ||
* | ||
* Overwritable configurations. | ||
* | ||
* !!! Do not touch this file unless you know what you're doing. | ||
* | ||
* @type {object} | ||
*/ | ||
const DefaultConfig = { | ||
InterfaceConfig: { | ||
storefront: { | ||
defaultHeaderComponent: 'ui/headers/StorefrontHeader', | ||
}, | ||
|
||
network: { | ||
defaultHeaderComponent: 'ui/headers/NetworkHeader', | ||
exploreScreen: { | ||
defaultCategoryComponent: 'ui/NetworkCategoryBlock', | ||
defaultCategoryComponentProps: { | ||
containerStyle: {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const configure = (target, ...sources) => { | ||
const isObject = (item) => item && typeof item === 'object' && !Array.isArray(item); | ||
|
||
if (typeof target === 'string') { | ||
target = DefaultConfig[target]; | ||
} | ||
|
||
if (!sources.length) { | ||
return target; | ||
} | ||
|
||
const source = sources.shift(); | ||
|
||
if (isObject(target) && isObject(source)) { | ||
for (const key in source) { | ||
if (isObject(source[key])) { | ||
if (!target[key]) { | ||
Object.assign(target, { [key]: {} }); | ||
} | ||
|
||
configure(target[key], source[key]); | ||
} else { | ||
Object.assign(target, { [key]: source[key] }); | ||
} | ||
} | ||
} | ||
|
||
return configure(target, ...sources); | ||
}; | ||
|
||
export { configure }; | ||
export default DefaultConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.