Skip to content

Commit

Permalink
adding diffBlob tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Oct 25, 2024
1 parent d728489 commit b0189e6
Show file tree
Hide file tree
Showing 308 changed files with 958 additions and 426 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-walls-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/primitives': minor
---

Adding diffBlob tokens
19 changes: 2 additions & 17 deletions .github/workflows/a11y-contrast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
GITHUB_RUN_ID: ${{ github.run_id }}
with:
script: |
const results = ${{ steps.check-results.outputs.failedResults }}
const results = `${{ steps.check-results.outputs.failedResults }}`
const WORKFLOW_SUMMARY_URL = `https://github.com/${{env.GITHUB_REPOSITORY}}/actions/runs/${{env.GITHUB_RUN_ID}}`
Expand All @@ -113,13 +113,10 @@ jobs:
repo: context.repo.repo
});
// get comments of token issues
let currentComments = comments.filter(comment => possibleTitles.some(titleStart => comment.body.includes(titleStart)));
// get token issue
const tokenCheckComment = comments.filter(comment => comment.body.includes("<!-- contrast check -->"));
// if token issue exists, update it
// if token issue exists, delete it
if(tokenCheckComment.length > 0) {
for (const comment of tokenCheckComment) {
await github.rest.issues.deleteComment({
Expand All @@ -144,18 +141,6 @@ jobs:
})
}
// if token issue exists, update it
if(currentComments.length > 0) {
await currentComments.map(comment => {
console.log('deleting comment', comment.id, comment)
github.rest.issues.deleteComment({
comment_id: comment.id,
owner: context.repo.owner,
repo: context.repo.repo,
})
})
}
Fail_action_on_contrast_failing:
needs: build
name: Fail action on contrast failing
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
113 changes: 113 additions & 0 deletions docs/storybook/stories/Demo/Diff/Diff.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
:root {
--line-number-cell-width: 40px;
--diff-line-minimum-height: 24px;
--diff-line-height: 24px;
--diff-action-bar-position: 0;
}
* {
box-sizing: border-box;
}
.DiffContainer {
border: 1px solid var(--borderColor-default);
border-radius: var(--borderRadius-medium);
overflow: hidden;
}
.diff-header {
font-size: var(--text-body-size-medium);
background-color: var(--bgColor-muted);
padding-inline: var(--control-medium-paddingInline-condensed);
padding-block: var(--base-size-12);
border-bottom: 1px solid var(--borderColor-default);
}
.diff-line {
--diff-num-bg: var(--diffBlob-emptyNum-bgColor);
--diff-line-bg: var(--diffBlob-emptyLine-bgColor);
&.type-default {
--diff-num-bg: var(--bgColor-default);
--diff-num-fg: var(--fgColor-default);
--diff-line-bg: var(--bgColor-default);
--diff-line-fg: var(--fgColor-default);
--diff-word-bg: var(--bgColor-default);
}
&.type-hunk {
--diff-num-bg: var(--diffBlob-hunkNum-bgColor-rest);
--diff-num-fg: var(--diffBlob-hunkNum-fgColor-rest);
--diff-line-bg: var(--diffBlob-hunkLine-bgColor);
--diff-line-fg: var(--diffBlob-hunkLine-fgColor);
}
&.type-addition {
--diff-num-bg: var(--diffBlob-additionNum-bgColor);
--diff-num-fg: var(--diffBlob-additionNum-fgColor);
--diff-line-bg: var(--diffBlob-additionLine-bgColor);
--diff-line-fg: var(--diffBlob-additionLine-fgColor);
--diff-word-bg: var(--diffBlob-additionWord-bgColor);
--diff-word-fg: var(--diffBlob-additionWord-fgColor);
}
&.type-deletion {
--diff-num-bg: var(--diffBlob-deletionNum-bgColor);
--diff-num-fg: var(--diffBlob-deletionNum-fgColor);
--diff-line-bg: var(--diffBlob-deletionLine-bgColor);
--diff-line-fg: var(--diffBlob-deletionLine-fgColor);
--diff-word-bg: var(--diffBlob-deletionWord-bgColor);
--diff-word-fg: var(--diffBlob-deletionWord-fgColor);
}
border-spacing: 0;
border-collapse: collapse;
.diff-line-word {
color: var(--diff-word-fg);
background-color: var(--diff-word-bg);
}
.diff-line-number {
width: 1%;
min-width: 50px;
line-height: 100%;
padding-right: var(--base-size-8, 8px) !important;
text-align: right;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
background-color: var(--diff-num-bg);
color: var(--diffBlob-hunk-fgColor-num-rest);
code {
line-height: var(--diff-line-height);
}
}
&.type-hunk {
.diff-line-number {
&:hover {
background-color: var(--diffBlob-hunk-bgColor-num-hover);
color: var(--diffBlob-hunk-fgColor-num-hover);
}
}
}
.diff-text-cell {
position: relative;
padding-right: var(--diff-line-height);
padding-left: var(--diff-line-height);
background-color: var(--diff-line-bg);
code {
color: var(--diff-line-fg);
div {
overflow: hidden;
word-wrap: break-word;
white-space: pre-wrap;
}
}
}
code {
font-family: var(
--fontStack-monospace,
ui-monospace,
SFMono-Regular,
SF Mono,
Menlo,
Consolas,
Liberation Mono,
monospace
);
font-size: 12px;
background-color: transparent;
padding: 0;
vertical-align: middle;
}
}
65 changes: 65 additions & 0 deletions docs/storybook/stories/Demo/Diff/Diff.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from 'react'
import './Diff.css'
import {Box, Link} from '@primer/react'

export default {
title: 'Testing/Diff',
parameters: {
controls: {hideNoControlsWarning: true},
options: {
showPanel: false,
},
},
}

type DiffLineType = 'hunk' | 'addition' | 'deletion' | 'default' | 'empty'

const DiffLine = ({
lineNumber = 11,
text = '// TODO: <span class="diff-line-word">1234</span> example line',
type = 'default',
}: {
lineNumber?: number
text?: string
type?: DiffLineType
}) => {
return (
<table width="100%" className={`diff-line type-${type}`}>
<tbody>
<tr>
<td aria-label={`Line ${lineNumber}`} data-line-number="true" className="diff-line-number" colSpan={1}>
<code>{type !== 'empty' ? lineNumber : ' '}</code>
</td>
<td className="diff-text-cell">
{type !== 'empty' && (
<code>
<div dangerouslySetInnerHTML={{__html: text}}></div>
</code>
)}
</td>
</tr>
</tbody>
</table>
)
}

const DiffHeader = ({filename = '.changeset/plenty-walls-buy.md'}: {filename?: string}) => {
return (
<div className="diff-header">
<Link muted>{filename}</Link>
</div>
)
}

export const Diff = () => {
return (
<div className="DiffContainer">
<DiffHeader />
<DiffLine lineNumber={11} type="hunk" />
<DiffLine lineNumber={12} type="addition" />
<DiffLine lineNumber={13} type="deletion" />
<DiffLine type="empty" />
<DiffLine lineNumber={14} type="default" />
</div>
)
}
Loading

0 comments on commit b0189e6

Please sign in to comment.