app-studio 0.7.12 → 0.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -10
- package/dist/app-studio.cjs.development.js +13 -0
- package/dist/app-studio.cjs.development.js.map +1 -1
- package/dist/app-studio.cjs.production.min.js +1 -1
- package/dist/app-studio.esm.js +13 -0
- package/dist/app-studio.esm.js.map +1 -1
- package/dist/app-studio.umd.development.js +13 -0
- package/dist/app-studio.umd.development.js.map +1 -1
- package/dist/app-studio.umd.production.min.js +1 -1
- package/docs/Hooks.md +3 -2
- package/docs/README.md +10 -12
- package/docs/Styling.md +6 -5
- package/package.json +1 -1
package/docs/README.md
CHANGED
|
@@ -561,7 +561,7 @@ Manages the application's theme, including color palettes, light/dark modes, and
|
|
|
561
561
|
|
|
562
562
|
**Context Values (via `useTheme`)**
|
|
563
563
|
|
|
564
|
-
* `getColor(colorName, mode?)`: Resolves a color string (e.g., `color-blue-500`, `theme-primary`) to its CSS value for the specified or current theme mode. You can also directly access specific theme mode colors using the `light-` or `dark-` prefix (e.g., `light-white` or `dark-red-200`), which will always use that specific theme mode's color regardless of the current theme setting.
|
|
564
|
+
* `getColor(colorName, mode?)`: Resolves a color string (e.g., `color-blue-500`, `theme-primary`) to its CSS value for the specified or current theme mode. You rarely need to call this — App-Studio components resolve color strings passed as props automatically. Use `getColor` only when passing a color to a non-App-Studio element or when you need the raw CSS value for a computed style. You can also directly access specific theme mode colors using the `light-` or `dark-` prefix (e.g., `light-white` or `dark-red-200`), which will always use that specific theme mode's color regardless of the current theme setting.
|
|
565
565
|
* `theme`: The merged theme configuration object.
|
|
566
566
|
* `themeMode`: The current mode ('light' or 'dark').
|
|
567
567
|
* `setThemeMode(mode)`: Function to change the theme mode.
|
|
@@ -622,32 +622,31 @@ App-Studio exports utility objects and functions.
|
|
|
622
622
|
|
|
623
623
|
## Colors (`utils/colors.ts`)
|
|
624
624
|
|
|
625
|
-
Defines the default color palettes (`defaultLightPalette`, `defaultDarkPalette`) and singleton colors (`defaultLightColors`, `defaultDarkColors`) used by `ThemeProvider`. You can import these if needed for custom theme configurations.
|
|
625
|
+
Defines the default color palettes (`defaultLightPalette`, `defaultDarkPalette`) and singleton colors (`defaultLightColors`, `defaultDarkColors`) used by `ThemeProvider`. You can import these if needed for custom theme configurations.
|
|
626
626
|
|
|
627
627
|
**Accessing Colors:**
|
|
628
628
|
|
|
629
|
+
App-Studio components resolve color strings automatically — just pass them as props. You don't need `getColor` for this:
|
|
630
|
+
|
|
629
631
|
```jsx
|
|
630
|
-
import {
|
|
631
|
-
import { View, Text } from './components/Components';
|
|
632
|
+
import { View, Text } from 'app-studio';
|
|
632
633
|
|
|
633
634
|
function ThemedComponent() {
|
|
634
|
-
const { getColor } = useTheme();
|
|
635
|
-
|
|
636
635
|
return (
|
|
637
636
|
<View
|
|
638
|
-
backgroundColor=
|
|
639
|
-
color=
|
|
637
|
+
backgroundColor="theme-primary" // Theme color
|
|
638
|
+
color="color-white" // Singleton color
|
|
640
639
|
borderRadius={8}
|
|
641
640
|
padding={10}
|
|
642
641
|
>
|
|
643
642
|
<Text>My Themed Content</Text>
|
|
644
643
|
|
|
645
|
-
{/*
|
|
644
|
+
{/* Mode-locked colors work the same way */}
|
|
646
645
|
<View
|
|
647
646
|
marginTop={10}
|
|
648
647
|
padding={8}
|
|
649
|
-
backgroundColor=
|
|
650
|
-
borderColor=
|
|
648
|
+
backgroundColor="light-blue-200" // Always light mode blue
|
|
649
|
+
borderColor="dark-red-500" // Always dark mode red
|
|
651
650
|
borderWidth={2}
|
|
652
651
|
borderStyle="solid"
|
|
653
652
|
borderRadius={4}
|
|
@@ -655,7 +654,6 @@ function ThemedComponent() {
|
|
|
655
654
|
<Text>Mixed theme mode colors</Text>
|
|
656
655
|
</View>
|
|
657
656
|
|
|
658
|
-
{/* Direct usage in component props without getColor */}
|
|
659
657
|
<View marginTop={10} padding={8}>
|
|
660
658
|
<Text color="light-white">Always light mode white text</Text>
|
|
661
659
|
<Text color="dark-blue-700" marginTop={4}>Always dark mode blue text</Text>
|
package/docs/Styling.md
CHANGED
|
@@ -408,22 +408,23 @@ Combine multiple state modifiers:
|
|
|
408
408
|
|
|
409
409
|
### Dynamic Theming
|
|
410
410
|
|
|
411
|
+
App-Studio components resolve theme color strings automatically. Pass the color name directly — no need for `getColor`:
|
|
412
|
+
|
|
411
413
|
```javascript
|
|
412
|
-
import { useTheme } from 'app-studio';
|
|
413
414
|
import { View } from 'app-studio';
|
|
414
415
|
|
|
415
416
|
function DynamicThemedComponent() {
|
|
416
|
-
const { getColor } = useTheme();
|
|
417
|
-
|
|
418
417
|
return (
|
|
419
418
|
<View
|
|
420
|
-
backgroundColor=
|
|
421
|
-
borderColor=
|
|
419
|
+
backgroundColor="theme-primary"
|
|
420
|
+
borderColor="theme-secondary"
|
|
422
421
|
/>
|
|
423
422
|
);
|
|
424
423
|
}
|
|
425
424
|
```
|
|
426
425
|
|
|
426
|
+
`getColor` from `useTheme` is only needed when passing a resolved CSS color to a non-App-Studio element (e.g., a third-party chart library) or to a computed value outside the prop system.
|
|
427
|
+
|
|
427
428
|
### CSS-in-JS Patterns
|
|
428
429
|
|
|
429
430
|
Use the `css` prop for complex styles:
|
package/package.json
CHANGED