@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/LICENSE +55 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/navigation-shell-layout-runtime.d.ts +29 -0
- package/dist/navigation-shell-layout-runtime.d.ts.map +1 -0
- package/dist/navigation-shell-layout-runtime.js +70 -0
- package/dist/navigation-shell-layout-runtime.js.map +1 -0
- package/dist/presentation-design-system.d.ts +144 -0
- package/dist/presentation-design-system.d.ts.map +1 -0
- package/dist/presentation-design-system.js +468 -0
- package/dist/presentation-design-system.js.map +1 -0
- package/dist/presentation-routed-surface-layout.d.ts +24 -0
- package/dist/presentation-routed-surface-layout.d.ts.map +1 -0
- package/dist/presentation-routed-surface-layout.js +38 -0
- package/dist/presentation-routed-surface-layout.js.map +1 -0
- package/dist/presentation-text-badge.d.ts +13 -0
- package/dist/presentation-text-badge.d.ts.map +1 -0
- package/dist/presentation-text-badge.js +23 -0
- package/dist/presentation-text-badge.js.map +1 -0
- package/package.json +59 -0
- package/src/index.ts +6 -0
- package/src/navigation-shell-layout-runtime.ts +135 -0
- package/src/presentation-design-system.ts +773 -0
- package/src/presentation-routed-surface-layout.ts +87 -0
- package/src/presentation-text-badge.ts +28 -0
- package/src/theme.css +7 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DesignIntent,
|
|
3
|
+
} from '@cohesivesystems/presentation-contracts'
|
|
4
|
+
import type { PresentationDesignSystem } from './presentation-design-system'
|
|
5
|
+
import {
|
|
6
|
+
projectPresentationDesignIntentDiagnostics,
|
|
7
|
+
type PresentationProjectionDiagnostic,
|
|
8
|
+
type PresentationSurface,
|
|
9
|
+
} from '@cohesivesystems/presentation-core'
|
|
10
|
+
|
|
11
|
+
export interface PresentationRoutedSurfaceLayoutContext {
|
|
12
|
+
readonly designSystem: PresentationDesignSystem
|
|
13
|
+
readonly surface: PresentationSurface | null
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PresentationRoutedSurfaceLayout {
|
|
17
|
+
readonly className: string
|
|
18
|
+
readonly contentClassName: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PresentationRoutedSurfaceLayoutDiagnosticsOptions {
|
|
22
|
+
readonly designSystem: PresentationDesignSystem
|
|
23
|
+
readonly sourceId: string
|
|
24
|
+
readonly surface: PresentationSurface | null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Resolves standard route-level layout chrome from presentation design intent.
|
|
29
|
+
*/
|
|
30
|
+
export function resolvePresentationRoutedSurfaceLayout({
|
|
31
|
+
designSystem,
|
|
32
|
+
surface,
|
|
33
|
+
}: PresentationRoutedSurfaceLayoutContext): PresentationRoutedSurfaceLayout {
|
|
34
|
+
return {
|
|
35
|
+
className: resolvePresentationRoutedSurfaceClassName(
|
|
36
|
+
surface?.rootView?.Design,
|
|
37
|
+
designSystem,
|
|
38
|
+
),
|
|
39
|
+
contentClassName: resolvePresentationRoutedSurfaceContentClassName(
|
|
40
|
+
surface?.rootView?.Design,
|
|
41
|
+
designSystem,
|
|
42
|
+
),
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function resolvePresentationRoutedSurfaceClassName(
|
|
47
|
+
design: DesignIntent | null | undefined,
|
|
48
|
+
designSystem: PresentationDesignSystem,
|
|
49
|
+
): string {
|
|
50
|
+
return designSystem.classNames.routedSurface.root({ design })
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function resolvePresentationRoutedSurfaceContentClassName(
|
|
54
|
+
design: DesignIntent | null | undefined,
|
|
55
|
+
designSystem: PresentationDesignSystem,
|
|
56
|
+
): string {
|
|
57
|
+
return designSystem.classNames.routedSurface.content({ design })
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function projectPresentationRoutedSurfaceLayoutDiagnostics({
|
|
61
|
+
designSystem,
|
|
62
|
+
sourceId,
|
|
63
|
+
surface,
|
|
64
|
+
}: PresentationRoutedSurfaceLayoutDiagnosticsOptions): readonly PresentationProjectionDiagnostic[] {
|
|
65
|
+
const rootView = surface?.rootView
|
|
66
|
+
if (!rootView) {
|
|
67
|
+
return []
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return projectPresentationDesignIntentDiagnostics({
|
|
71
|
+
design: rootView.Design,
|
|
72
|
+
ignoredFields: designSystem.diagnostics.routedSurfaceLayout.ignoredFields,
|
|
73
|
+
interpretedFields: designSystem.diagnostics.routedSurfaceLayout.interpretedFields,
|
|
74
|
+
message:
|
|
75
|
+
`Routed surface root view '${rootView.Name}' has design intent fields ` +
|
|
76
|
+
'that the standard routed-surface layout interpreter does not yet project.',
|
|
77
|
+
source: sourceId,
|
|
78
|
+
subject: {
|
|
79
|
+
id: rootView.Id,
|
|
80
|
+
kind: 'ViewDefinition',
|
|
81
|
+
name: rootView.Name,
|
|
82
|
+
},
|
|
83
|
+
suggestedNextStep:
|
|
84
|
+
'Extend the routed-surface layout interpreter for these design fields or move the policy into the design system.',
|
|
85
|
+
target: 'react-routed-surface-layout',
|
|
86
|
+
})
|
|
87
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported visual tones for compact text badges rendered with Tailwind
|
|
3
|
+
* utility classes.
|
|
4
|
+
*/
|
|
5
|
+
export type PresentationTextBadgeTone = 'amber' | 'red' | 'sky' | 'slate' | 'teal' | 'violet'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the Tailwind utility classes for a compact presentation text badge.
|
|
9
|
+
*
|
|
10
|
+
* The returned classes are intentionally static so Tailwind can discover them
|
|
11
|
+
* during content scanning.
|
|
12
|
+
*/
|
|
13
|
+
export function getPresentationTextBadgeClassName(tone: PresentationTextBadgeTone) {
|
|
14
|
+
switch (tone) {
|
|
15
|
+
case 'amber':
|
|
16
|
+
return 'border-amber-700/15 bg-amber-50 text-amber-800'
|
|
17
|
+
case 'red':
|
|
18
|
+
return 'border-red-700/15 bg-red-50 text-red-700'
|
|
19
|
+
case 'sky':
|
|
20
|
+
return 'border-sky-700/15 bg-sky-50 text-sky-700'
|
|
21
|
+
case 'teal':
|
|
22
|
+
return 'border-teal-700/15 bg-teal-50 text-teal-700'
|
|
23
|
+
case 'violet':
|
|
24
|
+
return 'border-violet-700/15 bg-violet-50 text-violet-700'
|
|
25
|
+
default:
|
|
26
|
+
return 'border-slate-950/10 bg-slate-100 text-slate-700'
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/theme.css
ADDED