Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update jobs pages to new design #122

Merged
merged 1 commit into from
Aug 3, 2023
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
4 changes: 3 additions & 1 deletion components/account/home/AccountInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ const css = useCssModule();
@blur="v$.country.$touch()"
/>

<div class="mt-8">
<div class="my-5 border-t border-grey-50" />

<div class="flex justify-end mt-8">
<RuiButton size="lg" :loading="loading" color="primary" @click="update()">
Update
</RuiButton>
Expand Down
12 changes: 7 additions & 5 deletions components/account/home/ChangePassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ const css = useCssModule();
autocomplete="new-password"
/>

<div :class="css.row" class="mt-8">
<div class="my-5 border-t border-grey-50" />

<div class="flex justify-end mt-8">
<span v-if="success" :class="css.success">
<CheckMarkIcon /> Your password has been changed.
</span>
<RuiButton
:disabled="v$.$invalid"
size="lg"
Expand All @@ -122,9 +127,6 @@ const css = useCssModule();
>
Change Password
</RuiButton>
<span v-if="success" :class="css.success">
<CheckMarkIcon /> Your password has been changed.
</span>
</div>
</CardContainer>
</template>
Expand All @@ -135,6 +137,6 @@ const css = useCssModule();
}
.success {
@apply flex flex-row ml-4 mt-6 text-rui-grey-800 transition duration-300 ease-in-out;
@apply flex flex-row mr-4 mt-6 text-rui-grey-800 transition duration-300 ease-in-out;
}
</style>
4 changes: 2 additions & 2 deletions components/account/home/DangerZone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ const css = useCssModule();

<template>
<CardContainer warning>
<TextHeading>
<TextHeading class="mt-4" no-margin>
<div class="text-rui-error">Delete account</div>
</TextHeading>

<p class="text-rui-text-secondary">
<p class="text-rui-text-secondary mt-1">
Proceeding will completely delete your account data. If you proceed you
will not be able to recover your account!
</p>
Expand Down
2 changes: 1 addition & 1 deletion components/content/ProseA.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ const css = useCssModule();

<style module lang="scss">
.link {
@apply hover:text-rui-text-secondary text-rui-primary;
@apply text-rui-primary hover:text-rui-primary-darker font-medium;
}
</style>
2 changes: 1 addition & 1 deletion components/content/ProseH2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const css = useCssModule();

<style lang="scss" module>
.heading {
@apply text-rui-text font-bold mt-6;
@apply text-rui-text font-bold mt-8 mb-6;
@apply text-[1.05rem] sm:text-[1.2rem] md:text-[1.35rem] 2xl:text-[1.5rem];
@apply leading-[1.4rem] sm:leading-[1.6rem] md:leading-[1.8rem] 2xl:leading-[2.2rem];
}
Expand Down
5 changes: 5 additions & 0 deletions components/content/ProseH5.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div class="text-h5 my-6">
<slot />
</div>
</template>
5 changes: 5 additions & 0 deletions components/content/ProseH6.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div class="text-h6 my-4 font-medium">
<slot />
</div>
</template>
3 changes: 3 additions & 0 deletions components/content/ProseHr.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div class="border-t border-black/[0.12] my-6" />
</template>
16 changes: 16 additions & 0 deletions components/content/ProseLi.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script setup lang="ts">
import { RuiIcon } from '@rotki/ui-library';
</script>

<template>
<li class="py-1 inline-flex w-full">
<RuiIcon
name="arrow-drop-right-line"
class="mr-2 text-rui-text-secondary min-w-[1.5rem]"
size="24"
/>
<span class="py-0.5">
<slot />
</span>
</li>
</template>
35 changes: 1 addition & 34 deletions components/content/ProseP.vue
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
<script setup lang="ts">
withDefaults(
defineProps<{
small?: boolean;
}>(),
{
small: false,
},
);
const css = useCssModule();
</script>

<template>
<p
:class="[
css.text,
{
[css.small]: small,
},
]"
>
<p class="text-rui-text-secondary text-body-1 mb-4">
<slot />
</p>
</template>

<style lang="scss" module>
.text {
@apply text-rui-grey-800 text-justify mt-4;
@apply text-[0.7875rem] sm:text-[0.9rem] md:text-[1.0125rem] 2xl:text-[1.2375rem];
@apply leading-[1.1375rem] sm:leading-[1.3rem] md:leading-[1.4625rem] 2xl:leading-[1.7875rem];
}
.small {
@apply text-[0.6125rem] sm:text-[0.7rem] md:text-[0.7875rem] 2xl:text-[0.9625rem];
@apply leading-[0.875rem] sm:leading-4 md:leading-[1.125rem] 2xl:leading-[1.375rem];
}
</style>
35 changes: 1 addition & 34 deletions components/content/ProseUl.vue
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
<script setup lang="ts">
withDefaults(
defineProps<{
small?: boolean;
}>(),
{
small: false,
},
);
const css = useCssModule();
</script>

<template>
<ul
:class="[
css.list,
{
[css.small]: small,
},
]"
>
<ul class="leading-5 text-body-2">
<slot />
</ul>
</template>

<style lang="scss" module>
.list {
@apply pl-8 list-disc mt-4;
@apply text-[0.7875rem] sm:text-[0.9rem] md:text-[1.0125rem] 2xl:text-[1.2375rem];
@apply leading-[1.1375rem] sm:leading-[1.3rem] md:leading-[1.4625rem] 2xl:leading-[1.7875rem];
}
.small {
@apply text-[0.6125rem] sm:text-[0.7rem] md:text-[0.7875rem] 2xl:text-[0.9625rem];
@apply leading-[0.875rem] sm:leading-4 md:leading-[1.125rem] 2xl:leading-[1.375rem];
}
</style>
2 changes: 1 addition & 1 deletion components/header/PageHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const logout = async () => {
<div>
<NavigationMenu />
</div>
<div class="flex items-center space-x-2 ml-6">
<div class="flex items-center space-x-2 ml-6 lg:ml-0">
<NuxtLink to="/home">
<RuiButton rounded color="primary">
{{ t('page_header.manage_premium') }}
Expand Down
25 changes: 25 additions & 0 deletions components/jobs/JobDescription.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script setup lang="ts">
defineProps<{
job: {
title?: string;
description?: string;
tags?: string[];
};
}>();
</script>

<template>
<div
class="p-4 rounded border border-rui-grey-300 space-y-4 hover:bg-rui-grey-100"
>
<div class="text-body-1">
{{ job.title }}
</div>
<div class="text-body-2 text-rui-text-secondary">
{{ job.description }}
</div>
<div v-if="job.tags && job.tags.length > 0" class="space-x-2.5">
<JobTag v-for="tag in job.tags" :key="tag" :tag="tag" />
</div>
</div>
</template>
32 changes: 32 additions & 0 deletions components/jobs/JobTag.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script setup lang="ts">
import { get } from '@vueuse/core';

const props = defineProps<{
tag: string;
}>();

const { tag } = toRefs(props);

const icon: ComputedRef<string> = computed(() => {
const value = get(tag);
return (
{
'full-time': 'timer-2-line',
'part-time': 'timer-2-line',
remote: 'user-location-line',
}[value] ?? ''
);
});
</script>

<template>
<RuiChip
class="capitalize hover:!bg-transparent py-1 !min-h-0"
:label="tag"
variant="outlined"
>
<template v-if="icon" #prepend>
<RuiIcon :name="icon" class="p-0.5" />
</template>
</RuiChip>
</template>
56 changes: 37 additions & 19 deletions composables/markdown.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { get, set } from '@vueuse/core';
import { groupBy } from 'graphql/jsutils/groupBy';
import type { MarkdownParsedContent } from '@nuxt/content/dist/runtime/types';
import type { ComputedRef, Ref } from 'vue';
import { logger } from '~/utils/logger';
import { replacePathPrefix } from '~/utils/api';
import { GITHUB_CONTENT_PREFIX } from '~/utils/constants';
import { CONTENT_PREFIX, LOCAL_CONTENT_PREFIX } from '~/utils/constants';
import { logger } from '~/utils/logger';

interface JobMarkdownContent extends MarkdownParsedContent {
export interface JobMarkdownContent extends MarkdownParsedContent {
link?: string;
open: boolean;
category: string;
tags: string[];
}

/**
Expand All @@ -18,6 +21,12 @@ export const useMarkdownContent = () => {
const openJobs: ComputedRef<JobMarkdownContent[]> = computed(() =>
get(jobs).filter((job) => job.open),
);
const groupedOpenJobsByCategory: ComputedRef<
Record<string, readonly JobMarkdownContent[]>
> = computed(() =>
Object.fromEntries(groupBy(get(openJobs), (item) => item.category ?? '')),
);

const firstJob: ComputedRef<JobMarkdownContent | null> = computed(
() => get(openJobs)[0] ?? null,
);
Expand All @@ -29,47 +38,55 @@ export const useMarkdownContent = () => {
const path = `/jobs`;

let foundJobs;
let prefix = CONTENT_PREFIX;

try {
const remotePath = `${GITHUB_CONTENT_PREFIX}${path}`;
// try to fetch from remote
foundJobs = await queryContent<JobMarkdownContent>(remotePath).find();
foundJobs = await queryContent<JobMarkdownContent>(
`${prefix}${path}`,
).find();
} catch (e: any) {
logger.error(e);
prefix = LOCAL_CONTENT_PREFIX;
// fallback to local if remote fails
foundJobs = await queryContent<JobMarkdownContent>(path).find();
foundJobs = await queryContent<JobMarkdownContent>(
`${prefix}${path}`,
).find();
}

set(
jobs,
foundJobs?.map((job) => {
job.link = replacePathPrefix(GITHUB_CONTENT_PREFIX, job._path);
job.link = replacePathPrefix(prefix, job._path);
return job;
}) ?? [],
);
};

const queryPrefixForJob = async (
prefix: typeof CONTENT_PREFIX,
path: string,
): Promise<JobMarkdownContent> => {
const prefixedPath = `${prefix}${path}`;
const data = await queryContent<JobMarkdownContent>(prefixedPath).findOne();
return {
...data,
link: replacePathPrefix(prefix, data?._path),
};
};

/**
* fetches a single markdown files within the jobs directory
*/
const loadJob = async (path: string): Promise<JobMarkdownContent> => {
try {
const remotePath = `${GITHUB_CONTENT_PREFIX}${path}`;
// try to fetch from remote
const data = await queryContent<JobMarkdownContent>(remotePath).findOne();
return {
...data,
link: replacePathPrefix(GITHUB_CONTENT_PREFIX, data?._path),
};
// try to fetch from prefix
return await queryPrefixForJob(CONTENT_PREFIX, path);
} catch (e: any) {
logger.error(e);

// fallback to local if remote fails
const data = await queryContent<JobMarkdownContent>(path).findOne();
return {
...data,
link: replacePathPrefix(GITHUB_CONTENT_PREFIX, data?._path),
};
return await queryPrefixForJob(LOCAL_CONTENT_PREFIX, path);
}
};

Expand All @@ -89,6 +106,7 @@ export const useMarkdownContent = () => {
return {
jobs,
openJobs,
groupedOpenJobsByCategory,
firstJob,
loadJob,
loadJobs,
Expand Down
Loading
Loading