Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into feat/translations
Browse files Browse the repository at this point in the history
  • Loading branch information
vabarbosa authored Nov 3, 2023
2 parents f83dff2 + d99791b commit 26118ae
Show file tree
Hide file tree
Showing 106 changed files with 7,736 additions and 2,105 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/check-for-nb.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions LOCALIZATION_CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ German (DE)

Thorsten Mühge | TMuehge
Zina Efchary | zinaefchary
Sasko Schirmer | c0nr3f

Spanish (ES_UN)

Expand Down Expand Up @@ -80,6 +81,7 @@ Jaejun Ko | Rapo1756
Eunmi Bae | likeyellow
Chanyang Im | imchanyang
Yuri Han | urihan
Minje Kim | Quantum-Tiger-K

Indonesian (ID)

Expand Down Expand Up @@ -113,3 +115,4 @@ Bin Liu | fjirsmliu
Weixiao Sun | sunwx17
Diksha Sharma | dikshasharma0795
Samanvay Sharma | starktech23
Saiprateek Dasgandhi | PSD-20
4 changes: 4 additions & 0 deletions TRANSLATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ First of all, **thank you** for showing interest in translating (localizing) Qis

**Please note that you must sign up separately if you want to join the localization project for [Qiskit Documentation](https://qiskit.org/documentation/). For signing up to join the Qiskit Documentation Localization project, please refer the steps outlined [here](https://github.com/qiskit-community/qiskit-translations/blob/master/README.md).**

$$\color{#D22222}\textsf{\Large\⚠\kern{0.2cm}\Large No new joining requests will be accepted in GitLocalize.}$$

$$\color{#D22222}\textsf{\qquad\kern{0.2cm}\Large This is due the upcoming changes on Qiskit Textbook.}$$

If you are interested in contributing to translating the Qiskit Textbook, please follow the instructions below.</br>

## Steps to participate in Qiskit textbook translations:
Expand Down
6 changes: 5 additions & 1 deletion converter/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import * as path from 'path'
import * as fs from 'fs-extra'
import { load as loadYAML } from 'js-yaml'

// NOTE: if changing this also update the same variable in 'server/utilities.ts'
const LATEST_TEXTBOOK_VERSION = 'v2'

const CWD = process.cwd()

// Get the languages to translate from the mathigon config file or throw an error
Expand All @@ -23,5 +26,6 @@ const workingTranslationsPath = path.join(CWD, 'working', 'translations')
export {
translationsLanguages,
workingContentPath,
workingTranslationsPath
workingTranslationsPath,
LATEST_TEXTBOOK_VERSION
}
9 changes: 8 additions & 1 deletion converter/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import * as fs from 'fs-extra'
import {
translationsLanguages,
workingContentPath,
workingTranslationsPath
workingTranslationsPath,
LATEST_TEXTBOOK_VERSION
} from './common'

const CWD = process.cwd()
Expand Down Expand Up @@ -92,11 +93,17 @@ const prepare = function (language: string) {
copyNotebookAssets(notebooks, working, (src: string, dest: string) => {
return path.dirname(src).split(path.sep).indexOf(nbImagesDirName) > -1
})
copyNotebookAssets(`${notebooks}${path.sep}${LATEST_TEXTBOOK_VERSION}`, working, (src: string, dest: string) => {
return path.dirname(src).split(path.sep).indexOf(nbImagesDirName) > -1
})

// copy over notebook `resources/`
copyNotebookAssets(notebooks, working, (src: string, dest: string) => {
return path.dirname(src).split(path.sep).indexOf(nbResourcesDirName) > -1
})
copyNotebookAssets(`${notebooks}${path.sep}${LATEST_TEXTBOOK_VERSION}`, working, (src: string, dest: string) => {
return path.dirname(src).split(path.sep).indexOf(nbResourcesDirName) > -1
})
}

const convert = function (language: string) {
Expand Down
2 changes: 1 addition & 1 deletion converter/textbook-converter/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ ipython>=6
nbformat>=4
nbconvert>=5
requests
pyyaml
pyyaml==5.3.1
4 changes: 0 additions & 4 deletions cypress/integration/sidebar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ describe('Sidebar', () => {
it('can be toggled on a laptop', () => {
cy.viewport('macbook-15')
cy.visit('/course/ch-prerequisites')
cy.get(sidebarSelector).should('be.visible')
cy.get(toggleSidebarSelector).click()
cy.get(sidebarSelector).should('be.not.visible')
cy.get(toggleSidebarSelector).click()
cy.get(sidebarSelector).should('be.visible')
})

it('can be toggled on a tablet', () => {
cy.viewport('ipad-2')
cy.visit('/course/ch-prerequisites')
cy.get(sidebarSelector).should('be.not.visible')
cy.get(toggleSidebarSelector).click()
cy.get(sidebarSelector).should('be.visible')
cy.get(toggleSidebarSelector).click()
cy.get(sidebarSelector).should('be.not.visible')
})
Expand Down
7 changes: 5 additions & 2 deletions frontend/scss/components/textbook__page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ main.body {

.c-textbook {
display: flex;
max-height: 100%;
min-height: calc(100vh - $qiskit-navbar-height);
height: calc(100vh - $qiskit-navbar-height - $one-xp-banner-height-desktop);
overflow: hidden;
position: relative;

@include mq($until: large) {
height: calc(100vh - $qiskit-navbar-height - $one-xp-banner-height-mobile);
}

@include mq($until: medium) {
display: grid;
grid-template-columns: 1fr 1fr;
Expand Down
7 changes: 5 additions & 2 deletions frontend/scss/variables/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ $textbook-page-width: 100%;
$qiskit-navbar-height: 3.5rem;
$textbook-page-banner-height: 40px;

$one-xp-banner-height-desktop: 3.25rem;
$one-xp-banner-height-mobile: 5rem;

$left-sidebar-width: 16rem;
$left-sidebar-width-hidden: 3rem;
$left-sidebar-width-sm: 3.5rem;
Expand All @@ -19,6 +22,6 @@ $spacing-unit-small: 12px;
$spacing-unit: 24px;

// Grid parameters.
$column-size-large: 4rem;
$column-size-large: 6rem;
$column-size-medium: 5rem;
$column-size-small: 5rem;
$column-size-small: 4rem;
8 changes: 8 additions & 0 deletions frontend/vue/components/CodeExercise/CodeExercise.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ExerciseActionsBar
class="code-exercise__editor-block__actions-bar"
:is-running="isKernelBusy"
:is-loading="isKernelLoading"
:is-api-token-needed="isApiTokenNeeded"
:run-enabled="isKernelReady"
:grade-enabled="isKernelReady && isGradingExercise"
Expand All @@ -35,6 +36,7 @@
@running="kernelRunning"
@finished="kernelFinished"
@kernelReady="kernelReady"
@kernelLoading="kernelLoading"
@correctAnswer="gradeSuccess"
/>
<div
Expand Down Expand Up @@ -111,6 +113,7 @@ export default defineComponent({
initialCode: '',
isKernelBusy: false,
isKernelReady: false,
isKernelLoading: false,
hideInitialOutput: false,
isApiTokenNeeded: this.usesHardware,
id: 0
Expand Down Expand Up @@ -183,12 +186,17 @@ export default defineComponent({
kernelRunning () {
this.isKernelBusy = true
this.hideInitialOutput = true
this.isKernelLoading = false
},
kernelFinished () {
this.isKernelBusy = false
},
kernelReady () {
this.isKernelReady = true
this.isKernelLoading = false
},
kernelLoading () {
this.isKernelLoading = true
}
}
})
Expand Down
40 changes: 24 additions & 16 deletions frontend/vue/components/CodeExercise/CodeOutput.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div ref="outputDiv" class="code-output">
<div>
<div v-if="!kernel && !error" class="code-output__state-info">
<div v-if="kernelLoading && !error" class="code-output__state-info">
<bx-loading class="code-output__state-info__icon" assistive-text="Connecting to the server" type="small" />
{{ $translate('Connecting to the server') }}
</div>
Expand Down Expand Up @@ -45,6 +45,7 @@ export default defineComponent({
},
data () {
return {
kernelLoading: false,
kernelPromise: undefined as Promise<IKernelConnection> | undefined,
kernel: undefined as IKernelConnection | undefined,
outputArea: undefined as OutputArea | undefined,
Expand All @@ -53,19 +54,6 @@ export default defineComponent({
}
},
mounted () {
this.$emit('loadingKernel')
const outputDivRef = (this.$refs.outputDiv as HTMLDivElement)
this.kernelPromise = requestBinderKernel()
this.kernelPromise.then((kernel: IKernelConnection) => {
this.kernel = kernel
this.$emit('kernelReady')
this.outputArea = createOutputArea(outputDivRef)
}, (error: Error) => {
this.error = error.message
})
this.apiTokenPromise = getQiskitUser().then(user => user?.apiToken)
},
methods: {
Expand Down Expand Up @@ -103,9 +91,9 @@ export default defineComponent({
},
_executeCode (code: string) {
this.error = ''
this.outputArea!.setHidden(true)
this.kernelPromise!.then((kernel: IKernelConnection) => {
this._initKernel()!.then((kernel: IKernelConnection) => {
this.$emit('running')
this.outputArea!.setHidden(true)
try {
const requestFuture = kernel.requestExecute({ code })
this.setOutputFuture(requestFuture)
Expand All @@ -128,6 +116,26 @@ export default defineComponent({
}
})
},
_initKernel (): Promise<IKernelConnection> {
if (this.kernelPromise) {
return this.kernelPromise
}
this.$emit('kernelLoading')
this.kernelLoading = true
const outputDivRef = (this.$refs.outputDiv as HTMLDivElement)
this.kernelPromise = requestBinderKernel()
return this.kernelPromise.then((kernel: IKernelConnection) => {
this.kernelLoading = false
this.$emit('kernelReady')
this.outputArea = createOutputArea(outputDivRef)
return kernel
}, (error: Error) => {
this.error = error.message
}) as Promise<IKernelConnection>
},
setOutputFuture (future : IOutputShellFuture) {
this.outputArea!.future = future
},
Expand Down
23 changes: 21 additions & 2 deletions frontend/vue/components/CodeExercise/ExerciseActionsBar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<template>
<div class="exercise-actions-bar">
<button
v-if="!runEnabled && !isRunning && !isApiTokenNeeded"
class="exercise-actions-bar__button exercise-actions-bar__button_kernel"
@click="run(isApiTokenNeeded)"
:class="{'exercise-actions-bar__button exercise-actions-bar__button_disabled': isLoading}"
:disabled="isLoading"
>
{{ $translate('Start kernel and run') }}
</button>
<button
v-if="runEnabled && !isRunning && !isApiTokenNeeded"
class="exercise-actions-bar__button exercise-actions-bar__button_run"
Expand Down Expand Up @@ -32,6 +41,11 @@ import 'carbon-web-components/es/components/loading/loading'
export default defineComponent({
name: 'ExerciseActionsBar',
props: {
isLoading: {
type: Boolean,
required: false,
default: true
},
isRunning: {
type: Boolean,
required: false,
Expand Down Expand Up @@ -91,7 +105,7 @@ export default defineComponent({
&__button {
padding: $spacing-03;
width: $column-size-large;
width: $column-size-small;
max-width: 100%;
background-size: 200% 100%;
Expand All @@ -113,9 +127,14 @@ export default defineComponent({
cursor: not-allowed;
}
&_run {
&_run,
&_kernel {
@include bicolor-background($button-background-color-quaternary-dark, $button-background-color-quaternary);
}
&_kernel {
width: 2 * $column-size-medium;
}
}
&__indicator {
Expand Down
Loading

0 comments on commit 26118ae

Please sign in to comment.