Skip to content

Implement theme UI in V2 components #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cb5830c
Fix up existing TidCarouselV2 stories and components.
patcon Oct 12, 2024
20161bb
Added TidCarouselV2Static component and stories.
patcon Oct 12, 2024
8845d80
Added more stories to TidCarousel component.
patcon Oct 12, 2024
0b996f3
Added new stories for large numbers. Renamed to be more general. Ensu…
patcon Oct 12, 2024
ed6c59e
Convert TidCarouselV2Static to use basic theme-ui.
patcon Oct 14, 2024
ae13e3f
Set proper font-family in theme-ui.
patcon Oct 15, 2024
06b166b
Align proptypes for TidCarouselV2 and V2Static.
patcon Oct 15, 2024
3d546b3
Align TidCarouselV2 button height to V2Static.
patcon Oct 15, 2024
b4b255a
Allow switching between TidCarousel types in SelectionWidgetV2.
patcon Oct 15, 2024
8154c30
Was missing key from TidCarousel subcomponent.
patcon Oct 15, 2024
b0211aa
Test maxWidth on SelectionWidgetV2.
patcon Oct 15, 2024
9197aad
Shift number of rows in TidCarouselV2Static at breakpoint.
patcon Oct 15, 2024
4488330
Migrate some styling from style prop to theme-ui variants.
patcon Oct 15, 2024
106b336
Allow forwardRef on TidCarouselV2Static.
patcon Oct 15, 2024
1f5b1b8
Added theme-ui support to CurateV2 component, and made single-row at …
patcon Oct 15, 2024
30fd391
Aligned CurateV2Button styles and props.
patcon Oct 15, 2024
da80e1f
Merge branch 'main' into implement-theme-ui
patcon Oct 16, 2024
258f5c4
Renamed TidCarouselV2 to TidCarouselV2Animated.
patcon Oct 16, 2024
f732651
Added fractional percentage, instead of decimal.
patcon Oct 16, 2024
39ad05c
Aligned TidCarouselV2Static and Animated button props.
patcon Oct 16, 2024
8f4f869
More Aligning TidCarouselV2Animated with Static. Prep for theme-ui.
patcon Oct 16, 2024
85e5683
Using more styles from TidCarouselV2Static.
patcon Oct 16, 2024
d021613
Make TidCarouselV2 smoother when jumping to new row.
patcon Oct 16, 2024
cf75781
Merge branch 'main' into implement-theme-ui
patcon Oct 16, 2024
fc60b56
Aligned button style for TidCarouselV2Animated and Static.
patcon Oct 16, 2024
873fa6f
Get theme-ui working in TidCarouselV2Animated stories.
patcon Oct 16, 2024
e3ef028
Persist active state in button that's transitioning out.
patcon Oct 16, 2024
d8af9d5
Copied ExploreTid into our directory as ExploreTidV2.
patcon Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .storybook/decorators.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@ export const withThemeUi = (Story) => (
</ThemeProvider>
)

const customParticipationTheme = Object.assign({}, compdemAdminTheme)
customParticipationTheme.fonts.body = "Arial"
customParticipationTheme.buttons.primary.border = 0
customParticipationTheme.buttons.primary.borderRadius = 4
customParticipationTheme.buttons.secondary = {
...customParticipationTheme.buttons.primary,
color: 'darkGray',
bg: 'lightGray',
fontFamily: 'body',
cursor: 'pointer'
}
customParticipationTheme["letterSpacings"] = {
button: 0.75,
}
customParticipationTheme.colors["polisBlue"] = "#03a9f4"
customParticipationTheme.colors["darkGray"] = "rgb(100,100,100)"
customParticipationTheme.colors["lightGray"] = "rgb(235,235,235)"

export const withParticipationThemeUi = (Story) => (
<ThemeProvider theme={customParticipationTheme}>
<Story />
</ThemeProvider>
)

export const withDelibThemeUi = (Story) => (
<ThemeProvider theme={haiDelibTheme}>
<Story />
Expand Down
2 changes: 1 addition & 1 deletion stories/2.OurComponents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ As a helpful resource, here is a summary of existing components (each a **clicka

- <LinkTo kind="compdem/client-participation/CivicTechTO/CurateV2" story="Interactive">`CurateV2`</LinkTo>
(Replaces <LinkTo kind="compdem/client-participation/Curate" story="Interactive">`Curate`</LinkTo>)
- <LinkTo kind="compdem/client-participation/CivicTechTO/TidCarouselV2" story="Interactive">`TidCarouselV2`</LinkTo>
- <LinkTo kind="compdem/client-participation/CivicTechTO/TidCarouselV2Animated" story="Interactive">`TidCarouselV2Animated`</LinkTo>
and <LinkTo kind="compdem/client-participation/CivicTechTO/TidCarouselV2Static" story="Interactive">`TidCarouselV2Static`</LinkTo>
(Replaces <LinkTo kind="compdem/client-participation/TidCarousel" story="Interactive">`TidCarousel`</LinkTo>)
- <LinkTo kind="compdem/client-participation/CivicTechTO/SelectionWidgetV2" story="Interactive">`SelectionWidgetV2`</LinkTo>
Expand Down
75 changes: 38 additions & 37 deletions stories/compdem/client-participation/CivicTechTO/CurateV2.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,75 @@
/** @jsx jsx */
import { jsx, Box } from 'theme-ui'

import React from 'react'
import * as globals from '../../../../codebases/compdem/client-participation/vis2/components/globals'

export const CurateV2Button = ({isSelected, onCurateButtonClick, style, children}) => {
const colors = {
polisBlue: "#03a9f4",
darkGray: "rgb(100,100,100)",
lightGray: "rgb(235,235,235)",
}
const buttonStyle = {
...style,
border: 0,
cursor: "pointer",
borderRadius: 4,
fontSize: 14,
padding: "6px 12px",
letterSpacing: 0.75,
// fontWeight: isSelected ? 700 : 500,
textShadow: isSelected ? "0 0 .65px #fff" : null,
backgroundColor: isSelected ? colors.polisBlue : colors.lightGray,
color: isSelected ? "white" : colors.darkGray,
export const CurateV2Button = React.forwardRef(({isSelected, handleClick, style, children, ...rest}, ref) => {
const styles = {
button: {
...style,
fontSize: 14,
letterSpacing: 0.75,
variant: isSelected ? "buttons.primary" : "buttons.secondary",
textShadow: isSelected ? "0 0 .65px #fff" : null,
},
}
return (
<button style={buttonStyle} role="tab" aria-selected={isSelected} onClick={onCurateButtonClick}>
<Box as="button" ref={ref} sx={styles.button} onClick={handleClick} {...rest}>
{children}
</button>
</Box>
)
}
})

const CurateV2 = ({selectedTidCuration, handleCurateButtonClick = () => {}, math}) => {
const GROUP_COUNT = math["group-clusters"].length
const styles = {
container: {
display: "flex",
flexDirection: "column",
rowGap: 5,
flexDirection: ["column-reverse", "row"],
gap: "5px",
rowGap: "5px",
},
groupContainer: {
display: "flex",
gap: 5,
flex: [1, "1 1 calc(2*100% / 3)"],
gap: "5px",
},
groupButton: {
height: 35,
flex: 1,
},
majorityContainer: {
flex: [1, "1 1 calc(100% / 3)"],
},
majorityButton: {
height: 35,
width: "100%",
},
}
const groups = ['A', 'B', 'C', 'D', 'E']

return(
<div style={styles.container} role="tablist">
<div style={styles.groupContainer}>
<div sx={styles.container}>
<div sx={styles.majorityContainer}>
<CurateV2Button
handleClick={() => handleCurateButtonClick(globals.tidCuration.majority)}
isSelected={selectedTidCuration === globals.tidCuration.majority}
style={styles.majorityButton}
children="Diverse Majority Opinion"
/>
</div>
<div sx={styles.groupContainer}>
{groups.slice(0, GROUP_COUNT).map((groupLabel, index) => (
<CurateV2Button
key={groupLabel}
onCurateButtonClick={() => handleCurateButtonClick(index)}
handleClick={() => handleCurateButtonClick(index)}
isSelected={selectedTidCuration === index}
style={styles.groupButton}
>
{groupLabel}
</CurateV2Button>
children={groupLabel}
/>
))}
</div>
<CurateV2Button
onCurateButtonClick={() => handleCurateButtonClick(globals.tidCuration.majority)}
isSelected={selectedTidCuration === globals.tidCuration.majority}
style={styles.majorityButton}
>
Diverse Majority Opinion
</CurateV2Button>
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import * as globals from '../../../../codebases/compdem/client-participation/vis
import Strings from '../../../../codebases/compdem/client-participation/js/strings/en_us'
import CurateV2 from './CurateV2'
import { getMath } from '../../../../.storybook/utils'
import { withParticipationThemeUi } from '../../../../.storybook/decorators'

const mathResults = getMath()

export default {
component: CurateV2,
decorators: [withParticipationThemeUi],
argTypes: {
groupCount: {
options: [2, 3, 4],
Expand Down
Loading