Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@flexnative/theme-context

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flexnative/theme-context - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

dist/constants.d.ts

8

dist/colors.d.ts

@@ -5,7 +5,7 @@ /**

* @ Modified by: Redon Alla
* @ Modified time: 2024-10-20 13:05:09
* @ Modified time: 2024-10-27 16:07:16
* @ Description: Default colors for FlexNative framework. Support dark and light colors.
*/
import { BaseTheme } from './types';
export declare const light: BaseTheme;
export declare const dark: BaseTheme;
import { BaseColors } from './props';
export declare const light: BaseColors;
export declare const dark: BaseColors;

@@ -5,6 +5,8 @@ /**

* @ Modified by: Redon Alla
* @ Modified time: 2024-10-20 13:05:09
* @ Modified time: 2024-10-27 16:07:16
* @ Description: Default colors for FlexNative framework. Support dark and light colors.
*/
export const light = {
white: '#FFFFFF',
black: '#424242',
background: "#f8f8f8",

@@ -23,5 +25,8 @@ default: '#f5f5f5',

light: "#ebebeb",
primary: '#ff6358'
primary: '#ff6358',
overlay: '#00000021',
};
export const dark = {
white: '#FFFFFF',
black: '#424242',
default: '#404040',

@@ -40,4 +45,5 @@ background: "#000000",

light: "#ebebeb",
primary: '#ff6358'
primary: '#ff6358',
overlay: '#FFFFFF21',
};
//# sourceMappingURL=colors.js.map

@@ -5,3 +5,3 @@ /**

* @ Modified by: Redon Alla
* @ Modified time: 2024-10-20 13:06:06
* @ Modified time: 2024-11-05 22:00:06
* @ Description: Exports necessary props, classes for Theme Context.

@@ -11,3 +11,4 @@ */

export { default as ThemeProvider } from './ThemeProvider';
export type { BaseTheme, ThemeProviderProps, ThemeContextProps } from './types';
export type { BaseColors, ThemeProviderProps, ThemeContextProps } from './props';
export { createTheme } from './utilities';
export * from './colors';

@@ -5,3 +5,3 @@ /**

* @ Modified by: Redon Alla
* @ Modified time: 2024-10-20 13:06:06
* @ Modified time: 2024-11-05 22:00:06
* @ Description: Exports necessary props, classes for Theme Context.

@@ -11,3 +11,4 @@ */

export { default as ThemeProvider } from './ThemeProvider';
export { createTheme } from './utilities';
export * from './colors';
//# sourceMappingURL=index.js.map

@@ -5,9 +5,9 @@ /**

* @ Modified by: Redon Alla
* @ Modified time: 2024-10-20 13:06:30
* @ Modified time: 2024-10-27 19:53:28
* @ Description: Theme Context.
*/
import React from 'react';
import { ThemeContextProps } from './types';
import { ThemeContextProps } from './props';
declare const ThemeContext: React.Context<ThemeContextProps<any>>;
export declare const useThemeContext: () => ThemeContextProps<any>;
export default ThemeContext;

@@ -5,3 +5,3 @@ /**

* @ Modified by: Redon Alla
* @ Modified time: 2024-10-20 13:06:30
* @ Modified time: 2024-10-27 19:53:28
* @ Description: Theme Context.

@@ -8,0 +8,0 @@ */

@@ -5,3 +5,3 @@ /**

* @ Modified by: Redon Alla
* @ Modified time: 2024-10-20 13:06:47
* @ Modified time: 2024-11-05 21:58:52
* @ Description: Theme Provider

@@ -11,8 +11,13 @@ */

import { ColorSchemeName } from 'react-native';
import { BaseTheme, ThemeProviderProps } from './types';
import { BaseColors, BaseTheme, ThemeProviderProps } from './props';
interface StateProps<TColors> {
colors: BaseTheme & TColors;
colorScheme?: ColorSchemeName;
/**
* Default theme colors.
* You can add whatever values you want to the theme, and they will be merged with the default.
*/
colors: BaseColors & TColors;
/** Theme colorScheme {@link ColorSchemeName} */
scheme?: ColorSchemeName;
}
/**
/** ThemeContext for handling colors and scheme change.
* @template TColors

@@ -28,3 +33,3 @@ * @author Redon Alla <redon.alla@gmail.com>

and this method it is used to write the logic for reading the theme from your storage and render on your app.
@see Example <http://localhost:3000/docs/theme/ra-theme-multiple-themes>
@see Example <https://redonalla.github.io/flexnative/docs/theme/examples>
* @return Promise of type void {Promise<void>}

@@ -38,11 +43,11 @@ */

*/
abstract onChangeColorSchemeTheme(colorScheme: ColorSchemeName): Promise<void>;
abstract onChangeColorScheme(colorScheme: ColorSchemeName): Promise<void>;
/**
* This method it is used to change theme of your app.
* @param {BaseTheme & TColors} theme
* @param {BaseColors & TColors} theme
* @return Promise so you can write the logic for storing your theme on you preferred storage.
*/
abstract onChangeTheme(theme: BaseTheme & TColors): Promise<void>;
abstract onChangeTheme(theme: BaseTheme<TColors>): Promise<void>;
render(): React.JSX.Element;
}
export {};

@@ -5,19 +5,10 @@ /**

* @ Modified by: Redon Alla
* @ Modified time: 2024-10-20 13:06:47
* @ Modified time: 2024-11-05 21:58:52
* @ Description: Theme Provider
*/
import React from 'react';
import { Appearance } from 'react-native';
import { light, dark } from './colors';
import ThemeContext from './ThemeContext';
import { createTheme, defaultColors } from './utilities';
;
/**
* Return default theme.
* @param colorScheme
* @return default theme colors according device ColorSchemeName.
*/
function GetDefaultTheme(colorSchemeName) {
return colorSchemeName === 'dark' ? dark : light;
}
/**
/** ThemeContext for handling colors and scheme change.
* @template TColors

@@ -29,5 +20,5 @@ * @author Redon Alla <redon.alla@gmail.com>

super(props);
/** @type {StateProps<TColors>} */
this.state = {
colors: props.colors ?? GetDefaultTheme(Appearance.getColorScheme())
scheme: props.scheme,
colors: props.colors ?? defaultColors(props.scheme)
};

@@ -39,9 +30,8 @@ }

render() {
return (React.createElement(ThemeContext.Provider, { value: {
...this.state,
setTheme: this.onChangeTheme,
setColorScheme: this.onChangeColorSchemeTheme
} }, this.props.children));
return (React.createElement(ThemeContext.Provider, { value: createTheme(Object.assign({}, this.props, {
scheme: this.props.scheme,
colors: this.props.colors
})) }, this.props.children));
}
}
//# sourceMappingURL=ThemeProvider.js.map
{
"name": "@flexnative/theme-context",
"version": "0.0.1",
"version": "0.0.2",
"description": "React ThemeContext",

@@ -26,3 +26,10 @@ "main": "dist/index.js",

"license": "MIT",
"devDependencies": {}
"devDependencies": {},
"homepage": "https://redonalla.github.io/flexnative/",
"bugs": "https://github.com/RedonAlla/flexnative/issues",
"repository": {
"type": "git",
"url": "https://github.com/RedonAlla/flexnative.git",
"directory": "npm-packages/src/packages/context/ra-theme-context"
}
}
# 🎨 Theme
The ***FlexNative Theme Context*** is part of the **FlexNative** and is available under the `@flexnative/theme-context` NPM package.
FlexNative Theme Context is part of the FlexNative and is available under the `@flexnative/theme-context` NPM package.

@@ -9,2 +9,2 @@ The theme object is where you define your application's color palette.

For more details on how tu start and how to use read the [documentation](https://redonalla.github.io/ra-framework-docks/).
For more details on how to start and how to use read the [documentation](https://redonalla.github.io/flexnative/docs/theme).

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc