Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 10 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"prettier": "npx prettier . --write"
},
"dependencies": {
"@abgov/react-components": "6.7.1-alpha.1",
"@abgov/react-components": "6.8.0-alpha.2",
"@abgov/ui-components-common": "1.7.0",
"@abgov/web-components": "1.37.1-alpha.2",
"@abgov/web-components": "1.38.0-alpha.3",
"@faker-js/faker": "^8.3.1",
"highlight.js": "^11.8.0",
"js-cookie": "^3.0.5",
Expand Down
3 changes: 1 addition & 2 deletions src/components/version-language-switcher/HelpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function HelpButton() {
return (
<GoabTooltip content="Version and framework info">
<GoabIconButton ml={"xs"}
mb={"2xs"}
variant="color"
size="small"
icon="help-circle"
Expand All @@ -35,4 +34,4 @@ export function HelpButton() {
/>
</GoabTooltip>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
GoabIcon,
GoabPopover
} from "@abgov/react-components";

import {
ANGULAR_VERSIONS, getVersionedUrlPath, Language, LanguageVersion,
VERSIONED_ANGULAR_URL_SEGMENT,
Expand All @@ -16,7 +17,7 @@ export const VersionLanguageSwitcher = () => {
const {language, version, setLanguage, setVersion} = useContext(LanguageVersionContext);
const location = useLocation();
const navigate = useNavigate();
const [hash, setHash] = React.useState<string>(window.location.hash);
const [hash, setHash] = React.useState<string>(window.location.hash);

useEffect(() => {
function setLanguageAndVersionFromUrl() {
Expand All @@ -33,7 +34,7 @@ export const VersionLanguageSwitcher = () => {
setLanguageAndVersionFromUrl();
});

// popover collapses when Url hash tag changes
// popover collapses when Url hash tag changes
const generateHyperlink = (newValue: LanguageVersion | Language) => {
return hash === newValue ? "#" : `#${newValue}`;
};
Expand Down Expand Up @@ -85,30 +86,22 @@ export const VersionLanguageSwitcher = () => {
return str.charAt(0).toUpperCase() + str.slice(1);
}

const openLanguagePopOver = (e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault();
};

const openVersionPopOver = (e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault();
};

const getCurrentVersionLabel = (language: string, version: string) => {
if (language === "react") {
return version === "new" ? REACT_VERSIONS.NEW.label : REACT_VERSIONS.OLD.label;
} if (language === "angular") {
} if (language === "angular") {
return version === "new" ? ANGULAR_VERSIONS.NEW.label : ANGULAR_VERSIONS.OLD.label;
}
}

return (
<>
<div className="version-language-switcher">
<div className="version-language-switcher">
<GoabPopover
target={
<a className="version-language-switcher__heading" href="#" id="language-switcher" onClick={e => openLanguagePopOver(e)}>
<GoabIcon type="chevron-down" size="small"></GoabIcon> {capitalizeFirstLetter(language)}
</a>
<div className="menu-link">
<GoabIcon type="chevron-down" size="small"></GoabIcon>
{capitalizeFirstLetter(language)}
</div>
}
padded={false}>
<>
Expand All @@ -121,10 +114,10 @@ export const VersionLanguageSwitcher = () => {
</GoabPopover>

<GoabPopover target={
<a className="version-language-switcher__heading" href="#"
onClick={e => openVersionPopOver(e)}>
<GoabIcon type="chevron-down" size="small"></GoabIcon> {getCurrentVersionLabel(language, version)}
</a>
<div className="menu-link">
<GoabIcon type="chevron-down" size="small"></GoabIcon>
{getCurrentVersionLabel(language, version)}
</div>
} padded={false}>
<>
{["new", "old"].map(ver => (
Expand All @@ -134,7 +127,6 @@ export const VersionLanguageSwitcher = () => {
))}
</>
</GoabPopover>
</div>
</>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@
}

.version-language-switcher {
height: 20px;
display: flex;
flex-direction: row;
align-items: center; /* vertically align content */
gap: var(--goa-space-s);
margin-bottom: var(--goa-space-xs);
}

@media (max-width: 623px) {
Expand All @@ -55,4 +53,16 @@
gap: 0;
margin-bottom: var(--goa-space-3xs);
}
}
}

.menu-link {
display: flex;
align-items: center;
justify-content: center;
color: var(--goa-color-interactive-default);
}

.menu-link:hover {
color: var(--goa-color-interactive-hover);
text-decoration: underline;
}