-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* β¨ Add image background #2014 * π Gradient #2014 * π Some progres #2014 * β¨ Alignment #2014 * Change description #2014 * π¨ introduce Tailwind * π§ͺ Fix tests and lint * π¨ Fix lint #2014 * update colors to suit tailwind * update to colors * π Fix CI #2014 * update configuration of portable text * more tweaks * Fix type error #2014 * Fix types again #2014 * update block content and remove h1 from block content * π¨ update indentation * π¨ remove unused package * π¨ update heading titles * π¨ clean up unused * π¨ remove energy red as background * β¨ Animation improvements #2014 * π¨ Image below text for mobile devices #2014 * Merge main * π¨ rewrite other branch into this with modifications * π¨ render background container only if necessary * π¨ fix review comments * π¨ fix alignments when content should align * π¨ update scroll mobile * π¨ update and add light version * π¨ fix ff and safari before * π¨ tweaking --------- Co-authored-by: Padmaja <[email protected]>
- Loading branch information
1 parent
b33b095
commit 2706826
Showing
53 changed files
with
772 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function capitalizeFirstLetter(string: string): string { | ||
return string.charAt(0).toUpperCase() + string.slice(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { defineType, defineField, Rule } from 'sanity' | ||
|
||
export default defineType({ | ||
type: 'object', | ||
name: 'backgroundOptions', | ||
|
||
fields: [ | ||
defineField({ | ||
type: 'array', | ||
name: 'background', | ||
description: 'Select what type of background you want to apply', | ||
title: 'Background', | ||
of: [ | ||
{ name: 'backgroundImage', type: 'imageBackground', title: 'Image' }, | ||
{ | ||
title: 'Color', | ||
description: 'Default is white.', | ||
name: 'backgroundColor', | ||
type: 'colorlist', | ||
}, | ||
].filter((e) => e), | ||
options: { sortable: false }, | ||
validation: (Rule) => [ | ||
Rule.custom((background, context) => { | ||
return background?.length > 1 ? 'Only 1 background item' : true | ||
}), | ||
Rule.custom((background, context) => { | ||
if (background?.[0]._type === 'backgroundImage') { | ||
return background[0]?.image?.asset ? true : 'Image required' | ||
} | ||
return true | ||
}), | ||
], | ||
}), | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { defineType, defineField, Image } from 'sanity' | ||
import { RadioIconSelector } from '../../components' | ||
import { ContentRightImage, ContentLeftImage, ContentCenterImage } from '../../../icons' | ||
import { capitalizeFirstLetter } from '../../../helpers/formatters' | ||
|
||
export type ColorType = { | ||
title: string | ||
value: string | ||
} | ||
|
||
const contentAlignmentOptions = [ | ||
{ value: 'left', icon: ContentLeftImage }, | ||
{ value: 'center', icon: ContentCenterImage }, | ||
{ value: 'right', icon: ContentRightImage }, | ||
] | ||
|
||
export default defineType({ | ||
name: 'imageBackground', | ||
title: 'Image background', | ||
type: 'object', | ||
fields: [ | ||
defineField({ | ||
title: 'Image', | ||
name: 'image', | ||
type: 'image', | ||
options: { | ||
hotspot: true, | ||
collapsed: false, | ||
}, | ||
}), | ||
defineField({ | ||
title: 'Apply scroll animation', | ||
name: 'useAnimation', | ||
type: 'boolean', | ||
description: 'Animates content over the background image.', | ||
}), | ||
defineField({ | ||
title: 'Apply light gradient', | ||
name: 'useLight', | ||
type: 'boolean', | ||
description: 'Applies a white gradient over semi transparent background image.', | ||
}), | ||
defineField({ | ||
name: 'contentAlignment', | ||
title: 'Content Alignment', | ||
description: 'Select the content alignment on larger screens.', | ||
type: 'string', | ||
initialValue: 'left', | ||
components: { | ||
input: function ({ onChange, value }: { onChange: any; value: string }) { | ||
return ( | ||
<RadioIconSelector | ||
name="imageAlignmentSelector" | ||
options={contentAlignmentOptions} | ||
defaultValue={'left'} | ||
currentValue={value} | ||
onChange={onChange} | ||
/> | ||
) | ||
}, | ||
}, | ||
}), | ||
], | ||
|
||
preview: { | ||
select: { | ||
image: 'image', | ||
useAnimation: 'useAnimation', | ||
contentAlignment: 'contentAlignment', | ||
}, | ||
prepare({ image, useAnimation, contentAlignment }) { | ||
return { | ||
title: `Image background`, | ||
subtitle: `${capitalizeFirstLetter(contentAlignment) + ' aligned '} ${ | ||
useAnimation ? ' | Animated ' : '' | ||
} content`, | ||
media: image.asset, | ||
} | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.