Skip to content

Commit

Permalink
Merge branch 'main' into solidjs/get-gists-api
Browse files Browse the repository at this point in the history
  • Loading branch information
hdJerry authored Nov 17, 2022
2 parents e39e739 + 04d1158 commit 09d9ecd
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci-solidjs-tailwind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ jobs:

steps:
- uses: actions/checkout@v2
uses: pnpm/[email protected]
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v2
uses: pnpm/[email protected]
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
Expand All @@ -45,11 +47,13 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: pnpm/[email protected]
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v2
uses: pnpm/[email protected]
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
Expand All @@ -75,11 +79,13 @@ jobs:

steps:
- uses: actions/checkout@v2
uses: pnpm/[email protected]
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v2
uses: pnpm/[email protected]
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Switch,
Match,
} from 'solid-js';
import { CaretIcon, CloseIcon, CorrectIcon } from '../icons';
import { CaretIcon, CloseIcon, CorrectIcon } from '../Icons';

function clickOutside(el, accessor) {
const onClick = (e) => {
Expand Down
2 changes: 1 addition & 1 deletion solidjs-tailwind/src/components/RepoFilter/FilterText.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Show, splitProps } from 'solid-js';
import { CloseIcon } from '../icons';
import { CloseIcon } from '../Icons';

const modifyFilterTypeText = (filterText = 'test') => {
if (filterText.endsWith('s')) {
Expand Down
2 changes: 1 addition & 1 deletion solidjs-tailwind/src/components/RepoFilter/RepoFilter.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mergeProps, Show } from 'solid-js';
import { RepoBookIcon } from '../icons';
import { RepoBookIcon } from '../Icons';
import { FILTER_TYPE_OPTIONS, SORT_OPTIONS } from './data';
import FilterDropdown from './FilterDropdown';
import FilterText from './FilterText';
Expand Down
1 change: 1 addition & 0 deletions solidjs-tailwind/src/components/icons/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as TwitterIcon } from './TwitterIcon';
export { default as CaretIcon } from './caret';
export { default as CloseIcon } from './close';
export { default as CorrectIcon } from './correct';
Expand Down
10 changes: 5 additions & 5 deletions solidjs-tailwind/src/services/api.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const FetchApi = ({url, query, variables, headersOptions}) => {
const FetchApi = ({ url, query, variables, headersOptions }) => {
return new Promise((resolve, reject) => {
fetch(url, {
method: "POST",
method: 'POST',
headers: {
...headersOptions,
Accept: 'application/vnd.github+json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
variables
})
variables,
}),
})
.then((res) => res.json())
.then((res) => res.json())
.then((result) => {
resolve(result);
})
Expand Down
55 changes: 55 additions & 0 deletions solidjs-tailwind/src/services/queries/all-repos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
export const USER_REPOS_QUERY = `
query UserRepos(
$username: String!
$afterCursor: String
$beforeCursor: String
$orderBy: RepositoryOrder
$first: Int
$last: Int
) {
owner: user(login: $username) {
repositories(
first: $first
last: $last
after: $afterCursor
before: $beforeCursor
orderBy: $orderBy
ownerAffiliations: [OWNER]
) {
nodes {
id
name
description
stargazerCount
forkCount
isArchived
isFork
primaryLanguage {
id
color
name
}
languages(first: 10, orderBy: { direction: ASC, field: SIZE }) {
nodes {
color
name
id
}
}
isPrivate
visibility
updatedAt
owner {
login
}
}
pageInfo {
endCursor
startCursor
hasNextPage
hasPreviousPage
}
}
}
}
`;
52 changes: 52 additions & 0 deletions solidjs-tailwind/src/services/user-repos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useAuth } from "../auth";
import FetchApi from "./api";
import { USER_REPOS_QUERY } from "./queries/all-repos";

const getUserRepos = async ({
url
}) => {
const { authStore } = useAuth();
const data = {
url,
query: USER_REPOS_QUERY,
variable: null,
headersOptions: {
authorization: `Bearer ${authStore.token}`,
}
}
const resp = await FetchApi(data);
const nodes = resp?.owner?.repositories?.nodes;
const pageInfo = resp?.owner?.repositories?.pageInfo;

if (!nodes) {
return undefined;
}
const repos = nodes?.reduce((acc, repo) => {
return repo
? [
...acc,
{
id: repo.id,
name: repo.name,
description: repo.description,
stargazerCount: repo.stargazerCount,
forkCount: repo.forkCount,
primaryLanguage: {
name: repo.primaryLanguage?.name,
color: repo.primaryLanguage?.color,
},
visibility: repo.visibility,
updatedAt: repo.updatedAt,
owner: repo.owner,
},
]
: acc;
}, []);

return {
pageInfo,
repos
};
};

export default getUserRepos;

0 comments on commit 09d9ecd

Please sign in to comment.