Skip to content

Commit a39a440

Browse files
committed
demonstrate hash calculation for color strings
1 parent ab2042c commit a39a440

1 file changed

Lines changed: 52 additions & 71 deletions

File tree

src/components/Application/stories/ColorPalettes.stories.tsx

Lines changed: 52 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -726,80 +726,61 @@ const ColorPaletteConfigurator = ({
726726
<>
727727
<Section>
728728
<SectionHeader>
729-
<TitleSubsection>Allow text as color hash</TitleSubsection>
729+
<TitleSubsection>Allow text as direct color hash</TitleSubsection>
730730
</SectionHeader>
731731
<Spacing size="small" />
732732
<TagList>
733-
<Badge
734-
tagProps={{
735-
large: true,
736-
backgroundColor: utils.textToColorHash({
737-
text: "magenta",
738-
options: {
739-
enabledColors: currentLayoutColorList,
740-
returnValidColorsDirectly: true,
741-
},
742-
}) as string,
743-
}}
744-
>
745-
magenta
746-
</Badge>
747-
<Badge
748-
tagProps={{
749-
large: true,
750-
backgroundColor: utils.textToColorHash({
751-
text: "teal",
752-
options: {
753-
enabledColors: currentLayoutColorList,
754-
returnValidColorsDirectly: true,
755-
},
756-
}) as string,
757-
}}
758-
>
759-
teal
760-
</Badge>
761-
<Badge
762-
tagProps={{
763-
large: true,
764-
backgroundColor: utils.textToColorHash({
765-
text: "rgb(128,0,128)",
766-
options: {
767-
enabledColors: currentLayoutColorList,
768-
returnValidColorsDirectly: true,
769-
},
770-
}) as string,
771-
}}
772-
>
773-
rgb(128,0,128)
774-
</Badge>
775-
<Badge
776-
tagProps={{
777-
large: true,
778-
backgroundColor: utils.textToColorHash({
779-
text: "#00ffff",
780-
options: {
781-
enabledColors: currentLayoutColorList,
782-
returnValidColorsDirectly: true,
783-
},
784-
}) as string,
785-
}}
786-
>
787-
#00ffff
788-
</Badge>
789-
<Badge
790-
tagProps={{
791-
large: true,
792-
backgroundColor: utils.textToColorHash({
793-
text: "no valid color string",
794-
options: {
795-
enabledColors: currentLayoutColorList,
796-
returnValidColorsDirectly: true,
797-
},
798-
}) as string,
799-
}}
800-
>
801-
no valid color string
802-
</Badge>
733+
{"yellow purple magenta pink violet indigo cyan teal lime grey rgb(128,0,128) #00ffff no_valid_color_string"
734+
.toString()
735+
.split(" ")
736+
.map((text, index) => (
737+
<Badge
738+
key={index}
739+
tagProps={{
740+
large: true,
741+
backgroundColor: utils.textToColorHash({
742+
text,
743+
options: {
744+
enabledColors: currentLayoutColorList,
745+
returnValidColorsDirectly: true,
746+
},
747+
}) as string,
748+
}}
749+
>
750+
{text}
751+
</Badge>
752+
))}
753+
</TagList>
754+
</Section>
755+
<Spacing />
756+
<Section>
757+
<SectionHeader>
758+
<TitleSubsection>
759+
Allow text as color but look for nearest palette neighbour
760+
</TitleSubsection>
761+
</SectionHeader>
762+
<Spacing size="small" />
763+
<TagList>
764+
{"yellow purple magenta pink violet indigo cyan teal lime amber vermilion grey rgb(128,0,128) #00ffff no_valid_color_string"
765+
.toString()
766+
.split(" ")
767+
.map((text, index) => (
768+
<Badge
769+
key={index}
770+
tagProps={{
771+
large: true,
772+
backgroundColor: utils.textToColorHash({
773+
text,
774+
options: {
775+
enabledColors: currentLayoutColorList,
776+
returnValidColorsDirectly: false,
777+
},
778+
}) as string,
779+
}}
780+
>
781+
{text}
782+
</Badge>
783+
))}
803784
</TagList>
804785
</Section>
805786
<Spacing />

0 commit comments

Comments
 (0)