-
Notifications
You must be signed in to change notification settings - Fork 11
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
WRP-26847: Create theming "Hello" App #206
Draft
alexandrumorariu
wants to merge
25
commits into
develop
Choose a base branch
from
feature/WRP-26847
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
63c9350
added structure for theming app sample
stanca-pop-lgp 8028631
added new lines at the end of files
stanca-pop-lgp 056e246
Added color pickers and the dynamic Color hook.
alexandrumorariu cf92102
Added context for data handling.
alexandrumorariu d017f3a
added extra presets and switch items to handle dynamic skin
stanca-pop-lgp 389644a
aligned buttons in preview section
stanca-pop-lgp 01771fa
Finished all the functionality of the app.
alexandrumorariu 5c94c0f
Merge from origin.
alexandrumorariu e45cb5b
App starts with dynamicColor off.
alexandrumorariu a817852
Review fix
alexandrumorariu be8cc54
Review fixes.
alexandrumorariu 6a3e758
Review fix.
alexandrumorariu 13d463e
Git review fixes
alexandrumorariu fa589a4
Small fixes.
alexandrumorariu 7082c17
Review fix
alexandrumorariu 564f58b
Review fixes
alexandrumorariu c265c38
Update sandstone/theming-app/README.md
daniel-stoian-lgp cb9bb51
Change name of files
alexandrumorariu 3129f9a
Merge branch 'feature/WRP-26847' of https://github.com/enactjs/sample…
alexandrumorariu bea167b
WRP-28251: Create documentation for dynamic color mode (#208)
stanca-pop-lgp 35a7a44
WRP-26847: Save colors/presets using LS2 Request (#209)
adrian-cocoara-lgp 64e06e1
Review fixes.
alexandrumorariu fd0d1a7
Small fix
alexandrumorariu 40e4141
code review fixes
adrian-cocoara-lgp f9af17e
added explanatory comments in PresetPanel.js
adrian-cocoara-lgp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
sandstone/custom-skin/package.json → ...eature-custom-skin-generator/package.json
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,15 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
|
||
# testing | ||
coverage | ||
|
||
# production | ||
build | ||
dist | ||
|
||
# misc | ||
.DS_Store | ||
npm-debug.log |
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,20 @@ | ||||||
## Custom Colors Generator | ||||||
|
||||||
A sample Enact application that uses dynamic color change feature to style components and create a personalized theme. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Run `npm install` then `npm run serve` to have the app running on [http://localhost:8080](http://localhost:8080), where you can view it in your browser. | ||||||
|
||||||
This app will help you choose a preset theme and/or customize the Sandstone UI components for your application. | ||||||
On the left side of the app, you can see all the presets and/or customizable color fields, while on the right side is the `Theme Preview` area. | ||||||
Any value changes you make to the color pickers will be reflected in `Theme Preview`. | ||||||
|
||||||
#### Customize Themes | ||||||
|
||||||
The radio buttons on the first Panel allow you to choose a preset, including Sandstone default theme. | ||||||
You can also choose to activate dynamic color mode which will modify the luminosity and saturation of your theme colors depending on the current time. | ||||||
In addition to this, you can opt to adjust skin automatically, which means that the system will choose between Sandstone neutral and light modes according to the colors you have set. | ||||||
On the second Panel you can interact with colors by clicking the colored circle which will open the basic color picker. | ||||||
|
||||||
#### Reset Theme | ||||||
|
||||||
The `Reset` button will revert all the changes to the active selected preset. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to have a simple file structure and explanation of important file |
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,49 @@ | ||
{ | ||
"name": "pattern-ls2request-custom-colors", | ||
"version": "1.0.0", | ||
"description": "A general template for an Enact Sandstone application.", | ||
"author": "", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"serve": "enact serve", | ||
"pack": "enact pack", | ||
"pack-p": "enact pack -p", | ||
"watch": "enact pack --watch", | ||
"clean": "enact clean", | ||
"lint": "enact lint --strict .", | ||
"license": "enact license", | ||
"test": "enact test", | ||
"test-watch": "enact test --watch" | ||
}, | ||
"license": "UNLICENSED", | ||
"private": true, | ||
"repository": "", | ||
"enact": { | ||
"theme": "sandstone" | ||
}, | ||
"eslintConfig": { | ||
"extends": "enact-proxy/strict" | ||
}, | ||
"eslintIgnore": [ | ||
"node_modules/*", | ||
"build/*", | ||
"dist/*" | ||
], | ||
"dependencies": { | ||
"@enact/core": "^4.7.5", | ||
"@enact/i18n": "^4.7.5", | ||
"@enact/sandstone": "^2.7.9", | ||
"@enact/spotlight": "^4.7.5", | ||
"@enact/ui": "^4.7.5", | ||
"@enact/webos": "^4.7.2", | ||
"classnames": "^2.3.2", | ||
"ilib": "^14.18.0", | ||
"prop-types": "^15.8.1", | ||
"ramda": "^0.29.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"eslint-config-enact-proxy": "^1.0.6" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
sandstone/pattern-ls2request-custom-colors/resources/ilibmanifest.json
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,3 @@ | ||
{ | ||
"files": [] | ||
} |
10 changes: 10 additions & 0 deletions
10
sandstone/pattern-ls2request-custom-colors/screenTypes.json
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,10 @@ | ||
[ | ||
{"name": "pal", "pxPerRem": 12, "width": 1024, "height": 576, "aspectRatioName": "hdtv"}, | ||
{"name": "hd", "pxPerRem": 16, "width": 1280, "height": 720, "aspectRatioName": "hdtv"}, | ||
{"name": "fhd", "pxPerRem": 24, "width": 1920, "height": 1080, "aspectRatioName": "hdtv"}, | ||
{"name": "uw-uxga", "pxPerRem": 24, "width": 2560, "height": 1080, "aspectRatioName": "cinema"}, | ||
{"name": "qhd", "pxPerRem": 36, "width": 2560, "height": 1440, "aspectRatioName": "hdtv"}, | ||
alexandrumorariu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{"name": "wqhd", "pxPerRem": 32, "width": 3440, "height": 1440, "aspectRatioName": "cinema"}, | ||
{"name": "uhd", "pxPerRem": 48, "width": 3840, "height": 2160, "aspectRatioName": "hdtv", "base": true}, | ||
{"name": "uhd2", "pxPerRem": 96, "width": 7680, "height": 4320, "aspectRatioName": "hdtv"} | ||
] |
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,82 @@ | ||
import ThemeDecorator from '@enact/sandstone/ThemeDecorator'; | ||
import LS2Request from '@enact/webos/LS2Request'; | ||
import {useEffect, useState} from 'react'; | ||
|
||
import {generateStylesheet} from '../hooks/generateStylesheet'; | ||
import MainView from '../views/MainView'; | ||
import screenTypes from '../../screenTypes.json'; | ||
|
||
import {AppContext, customColorsContext} from '../constants'; | ||
|
||
const request = new LS2Request(); | ||
|
||
const defaultKeyThemeValue = JSON.stringify({ | ||
"version": "0.1", | ||
"activeTheme": "defaultTheme", | ||
"dynamicColor": "off", | ||
"handleSkin": "off", | ||
"backgroundColor": "#000000", | ||
"componentBackgroundColor": "#7D848C", | ||
"focusBackgroundColor": "#E6E6E6", | ||
"popupBackgroundColor": "#575E66", | ||
"subtitleTextColor": "#ABAEB3", | ||
"textColor": "#E6E6E6", | ||
colors: generateStylesheet( | ||
"#000000", | ||
"#7D848C", | ||
"#E6E6E6", | ||
"#575E66", | ||
"#ABAEB3", | ||
"#E6E6E6" | ||
) | ||
}); | ||
|
||
const App = (props) => { | ||
const [context, setContext] = useState(customColorsContext); | ||
const [responseStatus, setResponseStatus] = useState(false); | ||
|
||
useEffect(() => { | ||
// check if app is running on webOS system | ||
if (typeof window === 'object' && window.webOSSystem && window.webOSSystem.launchParams) { | ||
// make a GET call to service settings to check the value of `theme` key | ||
request.send({ | ||
service: 'luna://com.webos.service.settings/', | ||
method: 'getSystemSettings', | ||
parameters: { | ||
category: 'customUi', | ||
keys: ['theme'] | ||
}, | ||
onSuccess: (res) => { | ||
setResponseStatus(res.returnValue); | ||
// if `theme` key is populated, update the context with key value | ||
if (res.settings.theme !== '' && res) { | ||
const parsedKeyData = JSON.parse(res.settings.theme); | ||
setContext({...parsedKeyData}); | ||
// if `theme` key is an empty string, update the context with a default value, then make a SET call to service settings and set | ||
// `theme` key with a default value | ||
} else if (res.settings.theme === '') { | ||
seunghoh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
setContext(JSON.parse(defaultKeyThemeValue)); | ||
request.send({ | ||
service: 'luna://com.webos.service.settings/', | ||
method: 'setSystemSettings', | ||
parameters: { | ||
category: 'customUi', | ||
settings: { | ||
theme: defaultKeyThemeValue | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<AppContext.Provider value={{context, setContext}}> | ||
<MainView responseStatus={responseStatus} {...props} /> | ||
</AppContext.Provider> | ||
); | ||
}; | ||
|
||
export default ThemeDecorator({ri: {screenTypes}}, App); |
3 changes: 3 additions & 0 deletions
3
sandstone/pattern-ls2request-custom-colors/src/App/App.module.less
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,3 @@ | ||
.app { | ||
// general app styles | ||
} |
3 changes: 3 additions & 0 deletions
3
sandstone/pattern-ls2request-custom-colors/src/App/package.json
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,3 @@ | ||
{ | ||
"main": "App.js" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.