Skip to content

Commit c5d4e4f

Browse files
authored
Add lock button for repos
Dev
2 parents 97ef782 + b752361 commit c5d4e4f

File tree

4 files changed

+83
-9
lines changed

4 files changed

+83
-9
lines changed

filebrowser.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,7 @@ function createNewRepoInHTML() {
17191719
`+ repoIcon +`
17201720
<a class="name" contenteditable="plaintext-only" spellcheck="false" autocorrect="off" autocomplete="off" aria-autocomplete="list" autocapitalize="off" dir="auto"></a>
17211721
</div>
1722+
`+ lockIcon +`
17221723
<div class="push-wrapper">
17231724
`+ pushIcon +`
17241725
</div>
@@ -1732,6 +1733,21 @@ function createNewRepoInHTML() {
17321733
repoEl.scrollIntoViewIfNeeded();
17331734

17341735

1736+
// add lock button event listener
1737+
const lockButton = repoEl.querySelector('.lock');
1738+
let repoPrivate = false;
1739+
1740+
lockButton.addEventListener('click', () => {
1741+
1742+
// toggle lock
1743+
repoPrivate = lockButton.classList.toggle('locked');
1744+
1745+
// focus repo name
1746+
repoEl.querySelector('.name').focus();
1747+
1748+
});
1749+
1750+
17351751
// add push button event listener
17361752
const pushWrapper = repoEl.querySelector('.push-wrapper');
17371753

@@ -1747,7 +1763,7 @@ function createNewRepoInHTML() {
17471763

17481764
});
17491765

1750-
let pushListener = pushWrapper.addEventListener('click', pushNewRepoInHTML);
1766+
pushWrapper.addEventListener('click', pushNewRepoInHTML);
17511767

17521768

17531769
// on next frame
@@ -1774,6 +1790,9 @@ function createNewRepoInHTML() {
17741790
repoEl.querySelector('.name').blur();
17751791
repoEl.querySelector('.name').scrollTo(0, 0);
17761792

1793+
// disable lock button
1794+
lockButton.style.pointerEvents = 'none';
1795+
17771796

17781797
// validate repo name
17791798

@@ -1811,7 +1830,7 @@ function createNewRepoInHTML() {
18111830

18121831
// create new repo obj
18131832
const repoObj = createRepoObj((loggedUser + '/' + repoName), 'main', 'main',
1814-
true, null, true, false, true);
1833+
true, null, repoPrivate, false, true);
18151834

18161835
// add repo obj to modified repos
18171836
addRepoToModRepos(repoObj);
@@ -1833,7 +1852,7 @@ function createNewRepoInHTML() {
18331852

18341853

18351854
// push repo asynchronously
1836-
const newSha = git.createRepo(repoName, true);
1855+
const newSha = git.createRepo(repoName, repoPrivate);
18371856

18381857
}
18391858

full.css

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ body.notransition .bottom-wrapper {
271271

272272
.bottom-float .push-wrapper .push-svg {
273273
position: absolute;
274-
left: 11.5px;
274+
left: 12.5px;
275275
transition: .4s var(--cubic-function) left;
276276
}
277277

@@ -1272,10 +1272,51 @@ body:not(.mobile) .sidebar .header .title .branch-icon:active {
12721272
display: none;
12731273
}
12741274

1275+
.sidebar .repo .lock {
1276+
margin-right: calc(38px - var(--spacing-1));
1277+
}
1278+
1279+
.sidebar .repo .lock path {
1280+
opacity: 1 !important;
1281+
transition: .18s var(--ease-function) !important;
1282+
}
1283+
1284+
.sidebar .repo .lock:active #wrapper {
1285+
opacity: .5;
1286+
}
1287+
1288+
.sidebar .repo .lock #shackle {
1289+
stroke: currentColor;
1290+
stroke-width: 1.58px;
1291+
stroke-dasharray: 20px;
1292+
stroke-dashoffset: -3.4px;
1293+
stroke-linecap: round;
1294+
will-change: transform;
1295+
}
1296+
1297+
.sidebar .repo .lock.locked #shackle {
1298+
stroke-dashoffset: -1.1px;
1299+
animation: lock-click .14s .124s var(--ease-function);
1300+
}
1301+
1302+
.sidebar .repo .lock.locked #housing-fill {
1303+
fill: currentColor;
1304+
}
1305+
1306+
.sidebar .repo .lock.locked #plug {
1307+
fill: transparent;
1308+
}
1309+
1310+
@keyframes lock-click {
1311+
50% {
1312+
transform: translateY(0.5px);
1313+
}
1314+
}
1315+
12751316
.sidebar .item .push-wrapper {
1276-
width: 53.5px;
1317+
width: 53px;
12771318
position: absolute;
1278-
right: -1.5px;
1319+
right: -2px;
12791320
display: none;
12801321
}
12811322

@@ -1895,8 +1936,8 @@ body.mobile.expanded .cube-loader::after {
18951936

18961937
.push-svg {
18971938
overflow: visible;
1898-
width: 39.5px;
1899-
height: 39.5px;
1939+
width: 38px;
1940+
height: 38px;
19001941
pointer-events: none;
19011942
}
19021943
.push-svg #push, .push-svg #check {

utils.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,20 @@ const plusIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="16" viewBox="0
648648

649649
const arrowIcon = '<svg xmlns="http://www.w3.org/2000/svg" class="arrow" height="24" viewBox="0 0 24 24" width="24"> <path d="M0 0h24v24H0z" fill="none"></path> <path d="M9.29 6.71c-.39.39-.39 1.02 0 1.41L13.17 12l-3.88 3.88c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41L10.7 6.7c-.38-.38-1.02-.38-1.41.01z" fill="currentColor"></path> </svg>';
650650

651+
const lockIcon = `
652+
<svg class="lock roundbutton" fill="currentColor" width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
653+
<g id="wrapper">
654+
<g id="shackle-wrapper" transform="matrix(1.33362,0,0,1.20093,-4.00339,-1.60746)">
655+
<path id="shackle" d="M9,8.834L9,6C9,4.34 10.34,3 12,3C13.66,3 15,4.34 15,6L15,8.834L9,8.834Z" fill="none"></path>
656+
</g>
657+
<path id="housing" d="M18.026 8H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10a2.006 2.006 0 0 0-1.974-2ZM18 19c0 .55-.45 1-1 1H7c-.55 0-1-.45-1-1v-8c0-.55.45-1 1-1h10c.55 0 1 .45 1 1v8Z"></path>
658+
<path id="housing-fill" d="M18 19c0 .55-.45 1-1 1H7c-.55 0-1-.45-1-1v-8c0-.55.45-1 1-1h10c.55 0 1 .45 1 1v8Zm-6-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2Z" fill="transparent"></path>
659+
<path id="plug" d="M12 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2Z"></path>
660+
<path id="bounding-box" fill="none" d="M0 0h24v24H0z"></path>
661+
</g>
662+
</svg>
663+
`;
664+
651665
const pushIcon = `
652666
<svg class="push-svg" fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40.92 40.21">
653667
<g id="Group" transform="translate(-9.08 -8.23)">

worker/client-channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
// update worker name when updating worker
7-
const WORKER_NAME = 'codeit-worker-v518';
7+
const WORKER_NAME = 'codeit-worker-v521';
88

99

1010
// internal paths

0 commit comments

Comments
 (0)