@cohesivesystems/presentation-tailwind 0.1.0-alpha.1

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/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@cohesivesystems/presentation-tailwind",
3
+ "version": "0.1.0-alpha.1",
4
+ "type": "module",
5
+ "sideEffects": [
6
+ "./src/theme.css"
7
+ ],
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./theme.css": "./src/theme.css"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src/**/*.ts",
18
+ "src/**/*.tsx",
19
+ "!src/**/*.test.ts",
20
+ "!src/**/*.test.tsx",
21
+ "src/theme.css"
22
+ ],
23
+ "dependencies": {
24
+ "@cohesivesystems/presentation-core": "0.1.0-alpha.1",
25
+ "@cohesivesystems/presentation-contracts": "0.1.0-alpha.1"
26
+ },
27
+ "peerDependencies": {
28
+ "tailwindcss": ">=4"
29
+ },
30
+ "devDependencies": {
31
+ "typescript": "~5.9.3",
32
+ "vitest": "^4.1.7"
33
+ },
34
+ "license": "Apache-2.0",
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "description": "Tailwind CSS helpers and theme primitives for Cohesive presentation modules.",
39
+ "keywords": [
40
+ "cohesive",
41
+ "presentation",
42
+ "tailwindcss",
43
+ "theme"
44
+ ],
45
+ "author": "Cohesive Systems",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/cohesivesystems/cohesive.git",
49
+ "directory": "src/frontend/presentation-tailwind"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/cohesivesystems/cohesive/issues"
53
+ },
54
+ "homepage": "https://github.com/cohesivesystems/cohesive#readme",
55
+ "scripts": {
56
+ "build": "tsc -p tsconfig.json && node ../../../eng/fix-package-js-imports.mjs dist",
57
+ "test": "vitest run --passWithNoTests"
58
+ }
59
+ }
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export const cohesivePresentationTailwindPackageId =
2
+ 'cohesive.presentation.tailwind'
3
+ export * from './navigation-shell-layout-runtime'
4
+ export * from './presentation-design-system'
5
+ export * from './presentation-routed-surface-layout'
6
+ export * from './presentation-text-badge'
@@ -0,0 +1,135 @@
1
+ import type {
2
+ ProjectedNavigationShellLayout as CoreProjectedNavigationShellLayout,
3
+ } from '@cohesivesystems/presentation-core'
4
+ import {
5
+ projectNavigationShellLayoutDiagnostics as projectCoreNavigationShellLayoutDiagnostics,
6
+ projectPresentationDesignIntentDiagnostics,
7
+ resolveProjectedNavigationShellLayout as resolveCoreProjectedNavigationShellLayout,
8
+ type PresentationProjectionDiagnostic,
9
+ } from '@cohesivesystems/presentation-core'
10
+ import type { PresentationDesignSystem } from './presentation-design-system'
11
+ import type {
12
+ NavigationDefinition,
13
+ NavigationShellSlotDefinition,
14
+ } from '@cohesivesystems/presentation-contracts'
15
+
16
+ export type ProjectedNavigationShellLayout =
17
+ CoreProjectedNavigationShellLayout<
18
+ ProjectedNavigationShellFrameLayout,
19
+ ProjectedNavigationShellSlotLayout
20
+ >
21
+
22
+ export interface ProjectedNavigationShellFrameLayout {
23
+ readonly headerClassName: string
24
+ readonly headerContentClassName: string
25
+ readonly headerNavigationClassName: string
26
+ readonly rootClassName: string
27
+ }
28
+
29
+ export interface ProjectedNavigationShellSlotLayout {
30
+ readonly brandBadgeClassName: string
31
+ readonly brandSubtitleClassName: string
32
+ readonly brandTitleClassName: string
33
+ readonly navigationItemClassName: string
34
+ readonly rootClassName: string
35
+ }
36
+
37
+ export interface NavigationShellLayoutDiagnosticsOptions {
38
+ readonly designSystem: PresentationDesignSystem
39
+ readonly navigation: NavigationDefinition
40
+ readonly shellFrameRendererKeys?: readonly string[]
41
+ readonly shellSlots: readonly NavigationShellSlotDefinition[]
42
+ }
43
+
44
+ export function resolveProjectedNavigationShellLayout(
45
+ navigation: NavigationDefinition,
46
+ shellSlots: readonly NavigationShellSlotDefinition[],
47
+ designSystem: PresentationDesignSystem,
48
+ ): ProjectedNavigationShellLayout {
49
+ return resolveCoreProjectedNavigationShellLayout({
50
+ navigation,
51
+ resolveFrameLayout: () => resolveProjectedNavigationShellFrameLayout(navigation, designSystem),
52
+ resolveSlotLayout: (slot) => resolveProjectedNavigationShellSlotLayout(slot, designSystem),
53
+ shellSlots,
54
+ })
55
+ }
56
+
57
+ export function resolveProjectedNavigationShellFrameLayout(
58
+ navigation: NavigationDefinition,
59
+ designSystem: PresentationDesignSystem,
60
+ ): ProjectedNavigationShellFrameLayout {
61
+ const design = navigation.Shell.Design
62
+ return {
63
+ headerClassName: designSystem.classNames.navigationShell.header({ design }),
64
+ headerContentClassName: designSystem.classNames.navigationShell.headerContent({ design }),
65
+ headerNavigationClassName: designSystem.classNames.navigationShell.headerNavigation({ design }),
66
+ rootClassName: designSystem.classNames.navigationShell.root({ design }),
67
+ }
68
+ }
69
+
70
+ export function resolveProjectedNavigationShellSlotLayout(
71
+ slot: NavigationShellSlotDefinition,
72
+ designSystem: PresentationDesignSystem,
73
+ ): ProjectedNavigationShellSlotLayout {
74
+ const design = slot.Design
75
+ return {
76
+ brandBadgeClassName: designSystem.classNames.navigationShell.brandBadge({ design }),
77
+ brandSubtitleClassName: designSystem.classNames.navigationShell.brandSubtitle({ design }),
78
+ brandTitleClassName: designSystem.classNames.navigationShell.brandTitle({ design }),
79
+ navigationItemClassName: designSystem.classNames.navigationShell.navigationItem({ design }),
80
+ rootClassName: designSystem.classNames.navigationShell.slotRoot({ slot }),
81
+ }
82
+ }
83
+
84
+ export function projectNavigationShellLayoutDiagnostics({
85
+ designSystem,
86
+ navigation,
87
+ shellFrameRendererKeys,
88
+ shellSlots,
89
+ }: NavigationShellLayoutDiagnosticsOptions): readonly PresentationProjectionDiagnostic[] {
90
+ const diagnostics: PresentationProjectionDiagnostic[] = [
91
+ ...projectPresentationDesignIntentDiagnostics({
92
+ design: navigation.Shell.Design,
93
+ ignoredFields: designSystem.diagnostics.navigationShellFrame.ignoredFields,
94
+ interpretedFields: designSystem.diagnostics.navigationShellFrame.interpretedFields,
95
+ message:
96
+ `Navigation shell '${navigation.Shell.Id}' has design intent fields ` +
97
+ 'that the standard shell frame layout interpreter does not yet project.',
98
+ source: `navigation-shell:${navigation.Shell.Id}`,
99
+ subject: {
100
+ id: navigation.Shell.Id,
101
+ kind: 'NavigationShellDefinition',
102
+ },
103
+ suggestedNextStep:
104
+ 'Extend the shell frame layout interpreter for these design fields or remove the unused design intent.',
105
+ target: 'react-navigation-shell-frame-layout',
106
+ }),
107
+ ...shellSlots.flatMap((slot) =>
108
+ projectPresentationDesignIntentDiagnostics({
109
+ design: slot.Design,
110
+ ignoredFields: designSystem.diagnostics.navigationShellSlot.ignoredFields,
111
+ interpretedFields: designSystem.diagnostics.navigationShellSlot.interpretedFields,
112
+ message:
113
+ `Navigation shell slot '${slot.Id}' has design intent fields ` +
114
+ 'that the standard shell slot layout interpreter does not yet project.',
115
+ semanticInputs: [
116
+ 'Kind',
117
+ 'Placement',
118
+ ],
119
+ source: `navigation-shell:${navigation.Shell.Id}`,
120
+ subject: {
121
+ id: slot.Id,
122
+ kind: 'NavigationShellSlotDefinition',
123
+ },
124
+ suggestedNextStep:
125
+ 'Extend the shell slot layout interpreter for these design fields or remove the unused design intent.',
126
+ target: 'react-navigation-shell-slot-layout',
127
+ })),
128
+ ...projectCoreNavigationShellLayoutDiagnostics({
129
+ navigation,
130
+ shellFrameRendererKeys,
131
+ }),
132
+ ]
133
+
134
+ return diagnostics
135
+ }