Skip to content

Commit

Permalink
Merge branch 'bose/2341' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
BorghildSelle committed Jun 12, 2024
2 parents d794a7b + f91036d commit a3bb8ce
Show file tree
Hide file tree
Showing 19 changed files with 218 additions and 904 deletions.
19 changes: 9 additions & 10 deletions sanityv3/schemas/objects/promotion/promotion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@ import type { CustomValidatorResult, PortableTextBlock, Rule, ValidationError }
import type { ColorSelectorValue } from '../../components/ColorSelector'
import { EdsIcon } from '../../../icons'
import { Flags } from '../../../src/lib/datasetHelpers'
import { validateInternalOrExternalUrl } from '../../validations/validateInternalOrExternalUrl'

import routes from '../../routes'
import { filterByRoute } from '../../../helpers/referenceFilters'
import type { ValidationContext } from 'sanity'

const horizontalScrollValidation = (context: Promotion): true | ValidationError => {
const { promotion, useHorizontalScroll } = context
const promotionLengthValidation = (context: Promotion): true | ValidationError => {
const { promotion } = context
const promo = promotion[0]
const numberOfItems = promo._type === 'promoteTopics' ? promo.references?.length : promo.promotedArticles?.length
const MIN = 3
const MAX = useHorizontalScroll ? 6 : 3
const MAX = 3

const validateNumber = (length: number): true | ValidationError => {
if (length < MIN)
// @ts-ignore
return { message: `Must have at least ${MIN} items`, paths: ['promotion'] }
return { message: `Must have ${MIN} items`, paths: ['promotion'] }
if (length > MAX)
// @ts-ignore
return { message: `Maximum of ${MIN} items allowed`, paths: ['promotion'] }
return { message: `Must have ${MIN} items`, paths: ['promotion'] }

return true
}
Expand Down Expand Up @@ -74,10 +73,10 @@ export default {
],
validation: (Rule: Rule) =>
Rule.custom((value: Promotion): CustomValidatorResult => {
const typesToValidate = ['promoteTopics', 'promoteMagazine']
const typesToValidate = ['promoteTopics', 'promoteMagazine', 'promoteNews']

if (typesToValidate.includes(value.promotion[0]._type)) {
return horizontalScrollValidation(value)
return promotionLengthValidation(value)
}

return true
Expand Down Expand Up @@ -132,7 +131,7 @@ export default {
{
name: 'useHorizontalScroll',
title: 'Use horizontal scroll',
description: '(Deprecated)',
description: '(Deprecated) Not used anymore. Will be removed after an interval',
type: 'boolean',
initialValue: false,
},
Expand Down
18 changes: 2 additions & 16 deletions web/components/src/FormattedDateTime/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { HTMLAttributes } from 'react'
import styled from 'styled-components'
import { Icon } from '@equinor/eds-core-react'
import { calendar, time } from '@equinor/eds-icons'
import { Card } from '../Card'

const { StyledLandscapeCard, StyledPortraitCard } = Card

export type DateProps = {
datetime: string
Expand All @@ -30,16 +27,5 @@ export const StyledDate = styled.span<{ uppercase?: boolean }>`
}
`

const StyledIcon = styled(Icon)`
/* If the icons are inside a card they should be green */
${StyledLandscapeCard} &,
${StyledPortraitCard} & {
/* EDS Icon uses current color for fill */
color: var(--moss-green-100);
/* We need to trick the eye here */
/* margin-bottom: var(--space-4); */
}
`

export const DateIcon = (): JSX.Element => <StyledIcon data={calendar} />
export const TimeIcon = (): JSX.Element => <StyledIcon data={time} />
export const DateIcon = (): JSX.Element => <Icon data={calendar} className="text-norwegian-woods-100" />
export const TimeIcon = (): JSX.Element => <Icon data={time} className="text-norwegian-woods-100" />
212 changes: 0 additions & 212 deletions web/pageComponents/cards/EventsCard.tsx

This file was deleted.

Loading

0 comments on commit a3bb8ce

Please sign in to comment.