@@ -10,7 +10,6 @@ import {
1010 Heading ,
1111 Collection ,
1212 FlexContainerStyleProps ,
13- useTheme ,
1413} from '@aws-amplify/ui-react' ;
1514
1615import { Demo } from '@/components/Demo' ;
@@ -26,61 +25,78 @@ import {
2625const propsToCode = ( props ) => {
2726 const filteredProps = filterDemoProps ( props ) ;
2827 return `
28+ const items = [
29+ {
30+ title: 'Milford - Room #1',
31+ badges: ['Waterfront', 'Verified'],
32+ },
33+ {
34+ title: 'Milford - Room #2',
35+ badges: ['Mountain', 'Verified'],
36+ },
37+ ];
38+
2939<Collection
30- type='list'
40+ items={items}
41+ type="list"
3142${ objectEntriesToPropString ( Object . entries ( filteredProps ) ) }
3243>
33- {collectionItems}
44+ {(item, index) => (
45+ <Card
46+ key={index}
47+ borderRadius="medium"
48+ maxWidth="20rem"
49+ variation="outlined"
50+ >
51+ <Image
52+ src="/road-to-milford-new-zealand-800w.jpg"
53+ alt="Glittering stream with old log, snowy mountain peaks tower over a green field."
54+ />
55+ <View padding="xs">
56+ <Flex>
57+ {item.badges.map((badge) => (
58+ <Badge
59+ key={badge}
60+ backgroundColor={
61+ badge === 'Waterfront' ? 'blue.40'
62+ : badge === 'Mountain' ? 'green.40' : 'yellow.40'}
63+ >
64+ {badge}
65+ </Badge>
66+ ))}
67+ </Flex>
68+ <Divider padding="xs" />
69+ <Heading padding="medium">{item.title}</Heading>
70+ <Button variation="primary" isFullWidth>
71+ Book it
72+ </Button>
73+ </View>
74+ </Card>
75+ )}
3476</Collection>` ;
3577} ;
3678
37- export const CollectionDemo = ( ) => {
38- const defaultValues = {
39- direction : 'row' ,
40- gap : '20px' ,
41- wrap : 'nowrap' ,
42- } ;
43-
44- const { tokens } = useTheme ( ) ;
79+ const defaultValues = {
80+ direction : 'row' ,
81+ gap : '20px' ,
82+ wrap : 'nowrap' ,
83+ } ;
4584
85+ export const CollectionDemo = ( ) => {
4686 const collectionProps = useCollectionProps (
4787 demoState . get ( Collection . displayName ) || defaultValues
4888 ) ;
4989 const demoProps = [ 'alignContent' , 'alignItems' , 'direction' , 'gap' , 'wrap' ] ;
5090 const collectionDemoProps = getDemoProps ( collectionProps , demoProps ) ;
5191
52- const list = [
92+ const items = [
5393 {
5494 title : 'Milford - Room #1' ,
55- imageSrc : '/road-to-milford-new-zealand-800w.jpg' ,
56- imageAlt :
57- 'Glittering stream with old log, snowy mountain peaks tower over a green field.' ,
58- badges : [
59- {
60- color : 'lightblue' ,
61- text : 'Waterfront' ,
62- } ,
63- {
64- color : 'lightgreen' ,
65- text : 'Verified' ,
66- } ,
67- ] ,
95+ badges : [ 'Waterfront' , 'Verified' ] ,
6896 } ,
6997 {
7098 title : 'Milford - Room #2' ,
71- imageSrc : '/road-to-milford-new-zealand-800w.jpg' ,
72- imageAlt :
73- 'Glittering stream with old log, snowy mountain peaks tower over a green field.' ,
74- badges : [
75- {
76- color : tokens . colors . yellow [ 60 ] . value ,
77- text : 'Mountain' ,
78- } ,
79- {
80- color : 'lightgreen' ,
81- text : 'Verified' ,
82- } ,
83- ] ,
99+ badges : [ 'Mountain' , 'Verified' ] ,
84100 } ,
85101 ] ;
86102
@@ -89,12 +105,9 @@ export const CollectionDemo = () => {
89105 code = { propsToCode ( collectionDemoProps ) }
90106 propControls = { < CollectionPropControls { ...collectionProps } /> }
91107 >
92- < View
93- backgroundColor = { tokens . colors . background . secondary }
94- padding = { tokens . space . medium }
95- >
108+ < View backgroundColor = "neutral.20" padding = "1rem" >
96109 < Collection
97- items = { list }
110+ items = { items }
98111 type = "list"
99112 direction = {
100113 collectionProps . direction as FlexContainerStyleProps [ 'direction' ]
@@ -105,24 +118,34 @@ export const CollectionDemo = () => {
105118 { ( item , index ) => (
106119 < Card
107120 key = { index }
121+ borderRadius = "medium"
108122 maxWidth = "20rem"
109123 variation = "outlined"
110- borderRadius = "5px"
111124 >
112- < Image src = { item . imageSrc } alt = { item . imageAlt } />
113- < View padding = { tokens . space . xs } >
125+ < Image
126+ src = "/road-to-milford-new-zealand-800w.jpg"
127+ alt = "Glittering stream with old log, snowy mountain peaks tower over a green field."
128+ />
129+ < View padding = "xs" >
114130 < Flex >
115131 { item . badges . map ( ( badge ) => (
116- < Badge key = { badge . text } backgroundColor = { badge . color } >
117- { badge . text }
132+ < Badge
133+ key = { badge }
134+ backgroundColor = {
135+ badge === 'Waterfront'
136+ ? 'blue.40'
137+ : badge === 'Mountain'
138+ ? 'green.40'
139+ : 'yellow.40'
140+ }
141+ >
142+ { badge }
118143 </ Badge >
119144 ) ) }
120145 </ Flex >
121- < Divider padding = { `${ tokens . space . xxxs } 0` } />
122- < Heading level = { 6 } padding = { tokens . space . xxxs } >
123- { item . title }
124- </ Heading >
125- < Button isFullWidth = { true } variation = "primary" >
146+ < Divider padding = "xs" />
147+ < Heading padding = "medium" > { item . title } </ Heading >
148+ < Button variation = "primary" isFullWidth >
126149 Book it
127150 </ Button >
128151 </ View >
0 commit comments