/// import { recipe, UI } from "commontools"; interface User { name: string; age: number; active: boolean; profile: { bio: string; location: string; settings: { theme: string; notifications: boolean; }; }; } interface Config { theme: { primaryColor: string; secondaryColor: string; fontSize: number; }; features: { darkMode: boolean; beta: boolean; }; } interface State { user: User; config: Config; items: string[]; index: number; numbers: number[]; } export default recipe("PropertyAccess", (state) => { return { [UI]: (

Basic Property Access

{state.user.name}

Age: {state.user.age}

Active: {state.user.active ? "Yes" : "No"}

Nested Property Access

Bio: {state.user.profile.bio}

Location: {state.user.profile.location}

Theme: {state.user.profile.settings.theme}

Notifications:{" "} {state.user.profile.settings.notifications ? "On" : "Off"}

Property Access with Operations

Age + 1: {state.user.age + 1}

Name length: {state.user.name.length}

Uppercase name: {state.user.name.toUpperCase()}

Location includes city:{" "} {state.user.profile.location.includes("City") ? "Yes" : "No"}

Array Element Access

Item at index: {state.items[state.index]}

First item: {state.items[0]}

Last item: {state.items[state.items.length - 1]}

Number at index: {state.numbers[state.index]}

Config Access with Styles

Styled text

Theme-aware box

Complex Property Chains

{state.user.name + " from " + state.user.profile.location}

Font size + 2: {state.config.theme.fontSize + 2}px

Has beta and dark mode:{" "} {state.config.features.beta && state.config.features.darkMode ? "Yes" : "No"}

), }; });