-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from HunnySajid/feat/provenant-theme
feat: add dropdown for language selection
- Loading branch information
Showing
15 changed files
with
151 additions
and
47 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
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 |
---|---|---|
@@ -1,13 +1,20 @@ | ||
import en from '@src/_locales/en.json'; | ||
import es from '@src/_locales/es.json'; | ||
import es_419 from '@src/_locales/es-419.json'; | ||
import en from "@src/_locales/en.json"; | ||
import es from "@src/_locales/es.json"; | ||
import es_419 from "@src/_locales/es-419.json"; | ||
|
||
const existingLanguageCodes = ["en", "es", "es-419"]; | ||
export const languageCodeMap = { | ||
en: "English", | ||
es: "Spanish", | ||
"es-419": "Spanish (LA)", | ||
}; | ||
|
||
export * from "./localeContext"; | ||
export const defaultLocale = existingLanguageCodes.includes(navigator.language) ? navigator.language : 'en'; | ||
export const defaultLocale = existingLanguageCodes.includes(navigator.language) | ||
? navigator.language | ||
: "en"; | ||
export const messages = { | ||
en, | ||
es, | ||
"es-419": es_419 | ||
} | ||
"es-419": es_419, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React, { useState } from "react"; | ||
import styled from "styled-components"; | ||
|
||
const DropdownWrapper = styled.div` | ||
position: relative; | ||
display: inline-block; | ||
width: 100%; | ||
`; | ||
|
||
const DropdownButton = styled.button` | ||
padding: 10px; | ||
border: none; | ||
cursor: pointer; | ||
width: 100%; | ||
border-radius: 4px; | ||
color: ${({ theme }) => theme?.colors?.bodyColor}; | ||
background: ${({ theme }) => theme?.colors?.bodyBg}; | ||
border: ${({ theme }) => `1px solid ${theme?.colors?.bodyBorder}`}; | ||
`; | ||
|
||
const DropdownList = styled.ul` | ||
width: 100%; | ||
position: absolute; | ||
top: 100%; | ||
left: 0; | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
background: ${({ theme }) => theme?.colors?.bodyBg}; | ||
color: ${({ theme }) => theme?.colors?.bodyColor}; | ||
border: ${({ theme }) => `1px solid ${theme?.colors?.bodyBorder}`}; | ||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); | ||
`; | ||
|
||
const DropdownItem = styled.li` | ||
padding: 10px; | ||
cursor: pointer; | ||
&:hover { | ||
background-color: ${({ theme }) => theme?.colors?.secondary}; | ||
color: ${({ theme }) => theme?.colors?.subtext}; | ||
} | ||
`; | ||
|
||
export const Dropdown = ({ selectedOption, options, onSelect }) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const handleDropdownClick = () => { | ||
setIsOpen(!isOpen); | ||
}; | ||
|
||
const handleOptionClick = (option) => { | ||
setIsOpen(false); | ||
onSelect(option); | ||
}; | ||
|
||
return ( | ||
<DropdownWrapper> | ||
<DropdownButton onClick={handleDropdownClick}> | ||
{selectedOption?.label} | ||
</DropdownButton> | ||
{isOpen && ( | ||
<DropdownList> | ||
{options.map((option) => ( | ||
<DropdownItem | ||
key={option?.value} | ||
onClick={() => handleOptionClick(option)} | ||
> | ||
{option?.label} | ||
</DropdownItem> | ||
))} | ||
</DropdownList> | ||
)} | ||
</DropdownWrapper> | ||
); | ||
}; |
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 @@ | ||
export { Dropdown } from "./dropdown"; |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from "./button"; | ||
export * from "./drawer"; | ||
export * from "./typography"; | ||
export * from "./card"; | ||
export * from "./card"; | ||
export * from "./dropdown"; |
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
{ | ||
"title": "FaceBook", | ||
"logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/Facebook_Logo_2023.png/1200px-Facebook_Logo_2023.png", | ||
"icon":"https://cdn-icons-png.flaticon.com/128/3955/3955011.png", | ||
"title": "Keria", | ||
"logo": "https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png", | ||
"icon":"https://cdn-icons-png.flaticon.com/128/3291/3291695.png", | ||
"theme": { | ||
"colors": { | ||
"primary": "#4c6edf", | ||
"secondary": "#2ad881", | ||
"error": "#f55877", | ||
"heading": "#273444", | ||
"text": "#5A5252", | ||
"subtext": "#d3dce6", | ||
"primary": "green", | ||
"secondary": "#2d0457", | ||
"error": "red", | ||
"heading": "#5e2b8f", | ||
"text": "grey", | ||
"subtext": "brown", | ||
"white": "#ffffff", | ||
"black": "#373e49", | ||
"bodyBg": "#252430", | ||
"bodyBorder": "#252430", | ||
"bodyBg": "linear-gradient(90deg, rgba(2,0,36,1) 1%, rgba(125,67,214,1) 100%, rgba(0,212,255,1) 100%)", | ||
"bodyBorder": "#eeff04", | ||
"bodyColor": "#eeff04", | ||
"cardColor": "blue", | ||
"cardBg": "green" | ||
"cardColor": "green", | ||
"cardBg": "blue" | ||
} | ||
} | ||
} |
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