Skip to content
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
wants to merge 25 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
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 Sep 13, 2023
8028631
added new lines at the end of files
stanca-pop-lgp Sep 13, 2023
056e246
Added color pickers and the dynamic Color hook.
alexandrumorariu Sep 14, 2023
cf92102
Added context for data handling.
alexandrumorariu Sep 14, 2023
d017f3a
added extra presets and switch items to handle dynamic skin
stanca-pop-lgp Sep 14, 2023
389644a
aligned buttons in preview section
stanca-pop-lgp Sep 14, 2023
01771fa
Finished all the functionality of the app.
alexandrumorariu Sep 15, 2023
5c94c0f
Merge from origin.
alexandrumorariu Sep 15, 2023
e45cb5b
App starts with dynamicColor off.
alexandrumorariu Sep 15, 2023
a817852
Review fix
alexandrumorariu Sep 15, 2023
be8cc54
Review fixes.
alexandrumorariu Sep 15, 2023
6a3e758
Review fix.
alexandrumorariu Sep 20, 2023
13d463e
Git review fixes
alexandrumorariu Sep 20, 2023
fa589a4
Small fixes.
alexandrumorariu Sep 20, 2023
7082c17
Review fix
alexandrumorariu Sep 20, 2023
564f58b
Review fixes
alexandrumorariu Sep 20, 2023
c265c38
Update sandstone/theming-app/README.md
daniel-stoian-lgp Sep 20, 2023
cb9bb51
Change name of files
alexandrumorariu Sep 21, 2023
3129f9a
Merge branch 'feature/WRP-26847' of https://github.com/enactjs/sample…
alexandrumorariu Sep 21, 2023
bea167b
WRP-28251: Create documentation for dynamic color mode (#208)
stanca-pop-lgp Sep 29, 2023
35a7a44
WRP-26847: Save colors/presets using LS2 Request (#209)
adrian-cocoara-lgp Oct 12, 2023
64e06e1
Review fixes.
alexandrumorariu Oct 19, 2023
fd0d1a7
Small fix
alexandrumorariu Oct 19, 2023
40e4141
code review fixes
adrian-cocoara-lgp Oct 20, 2023
f9af17e
added explanatory comments in PresetPanel.js
adrian-cocoara-lgp Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "custom-skin",
"name": "custom-skin-generator",
"version": "1.0.0",
"description": "A general template for an Enact Sandstone application.",
"author": "",
Expand Down
15 changes: 15 additions & 0 deletions sandstone/pattern-ls2request-custom-colors/.gitignore
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
20 changes: 20 additions & 0 deletions sandstone/pattern-ls2request-custom-colors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Custom Colors Generator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Custom Colors Generator
## Custom Colors LS2Request pattern


A sample Enact application that uses dynamic color change feature to style components and create a personalized theme.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A sample Enact application that uses dynamic color change feature to style components and create a personalized theme.
A sample Enact application that how to customize a Sandstone color, save & load colors via webos setting service.


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.
Copy link
Member

Choose a reason for hiding this comment

The 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

49 changes: 49 additions & 0 deletions sandstone/pattern-ls2request-custom-colors/package.json
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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"files": []
}
10 changes: 10 additions & 0 deletions sandstone/pattern-ls2request-custom-colors/screenTypes.json
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"}
]
82 changes: 82 additions & 0 deletions sandstone/pattern-ls2request-custom-colors/src/App/App.js
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);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.app {
// general app styles
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"main": "App.js"
}
Loading