diff --git a/packages/chakra-components/src/components/Election/Results.tsx b/packages/chakra-components/src/components/Election/Results.tsx
index 208064a..7f4109e 100644
--- a/packages/chakra-components/src/components/Election/Results.tsx
+++ b/packages/chakra-components/src/components/Election/Results.tsx
@@ -1,4 +1,4 @@
-import { Box, chakra, ChakraProps, Flex, Progress, Text, useMultiStyleConfig } from '@chakra-ui/react'
+import { Box, chakra, ChakraProps, Flex, Image, Progress, Text, useMultiStyleConfig } from '@chakra-ui/react'
import { useClient, useDatesLocale, useElection } from '@vocdoni/react-providers'
import {
ElectionResultsTypeNames,
@@ -9,6 +9,7 @@ import {
PublishedElection,
} from '@vocdoni/sdk'
import { format } from 'date-fns'
+import { Markdown } from '../layout'
const percent = (result: number, total: number) => ((Number(result) / total) * 100 || 0).toFixed(1) + '%'
export const results = (result: number, decimals?: number) =>
@@ -53,25 +54,46 @@ export const ElectionResults = (props: ElectionResultsProps) => {
{localize('results.title', { title: q.title.default })}
- {choices.map((c: any, i: number) => (
-
- {totals && (
- <>
- {c.title.default}
-
- {localize('results.votes', {
- votes: results(c.results, decimals) || 0,
- percent: percent(results(c.results, decimals), totals[idx]),
- })}
-
-
- >
- )}
-
- ))}
+ {choices.map((c: any, i: number) => {
+ if (!totals) return null
+
+ const meta = c.meta ?? {}
+ const description = meta.description as string | undefined
+ const imageSrc = meta.image?.default as string | undefined
+ const hasDescription = !!description
+ const hasImage = !!imageSrc
+
+ return (
+
+
+
+
+
+
+ {c.title.default}
+
+ {localize('results.votes', {
+ votes: results(c.results, decimals) || 0,
+ percent: percent(results(c.results, decimals), totals[idx]),
+ })}
+
+
+
+ {hasDescription && {description}}
+
+
+ {hasImage && (
+
+
+
+ )}
+
+
+ )
+ })}
)
diff --git a/packages/chakra-components/src/theme/results.ts b/packages/chakra-components/src/theme/results.ts
index fc12024..0dededf 100644
--- a/packages/chakra-components/src/theme/results.ts
+++ b/packages/chakra-components/src/theme/results.ts
@@ -19,6 +19,14 @@ export const resultsAnatomy = [
'choiceTitle',
// choice number of votes
'choiceVotes',
+ // choice body
+ 'choiceBody',
+ // choice description
+ 'choiceDescription',
+ // choice image wrapper
+ 'choiceImageWrapper',
+ // choice image
+ 'choiceImage',
] as const
const { defineMultiStyleConfig, definePartsStyle } = createMultiStyleConfigHelpers(resultsAnatomy)
@@ -39,6 +47,30 @@ const baseStyle = definePartsStyle({
textAlign: 'center',
fontWeight: 'bold',
},
+ choiceBody: {
+ position: 'relative',
+ px: 3,
+ py: 2,
+ align: 'center',
+ justify: 'space-between',
+ },
+ choiceDescription: {
+ color: 'black',
+ pl: 2,
+ },
+ choiceImageWrapper: {
+ ml: 4,
+ flexShrink: 0,
+ w: ['90px', '130px'],
+ h: ['60px', '80px'],
+ borderRadius: 'md',
+ overflow: 'hidden',
+ },
+ choiceImage: {
+ w: '100%',
+ h: '100%',
+ objectFit: 'cover',
+ },
})
export const ResultsTheme = defineMultiStyleConfig({