Skip to content

Commit

Permalink
Add video block
Browse files Browse the repository at this point in the history
  • Loading branch information
sebousan committed Dec 5, 2023
1 parent 8865811 commit 7350a74
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 3 deletions.
25 changes: 24 additions & 1 deletion admin/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ input[id*='color'] {
}
[class*='TopBarContainer'] + div label {
font-size: 12px;
background-color: transparent !important;
}
[class*='ControlContainer'] > label::after {
content: none;
content: none !important;
}
[class*='ControlContainer'] > div {
/* border: 1px dashed var(--grey); */
Expand Down Expand Up @@ -347,6 +348,28 @@ div[id^='documents-field'] {
width: 49%;
}

/* Video */
[id^='video-field'] {
background-color: var(--lightgrey) !important;
}
[id^='video-field'] > div:nth-child(2) {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
[id^='video-field'] > div:nth-child(2) > div {
flex-basis: 49%;
}
[id^='video-field'] [class*='-ControlContainer']:has(> [for^='controls-field']),
[id^='video-field'] [class*='-ControlContainer']:has(> [for^='screenshot-field']),
[id^='video-field'] [class*='-ControlContainer']:has(> [for^='autoplay-field']) {
flex-basis: 33%;
flex-direction: column;
}
[id^='video-field'] [class*='ControlContainer'] > div {
padding-left: 0;
}

/* TAXONOMIES */
[class*='-ControlContainer']:has([id^='reference']) {
float: left;
Expand Down
21 changes: 21 additions & 0 deletions admin/app/blocks/video.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { background } from '../fields/background.js';
import { grid } from '../fields/grid.js';
import { heading } from '../fields/heading.js';
import { t } from '../i18n/translater.js';
import { video } from '../fields/video.js';

export const block_video = {
name: 'video',
widget: 'object',
label: t.blocks.video,
required: false,
i18n: true,
collapsed: false,
summary: '{{heading.title}}',
fields: [
heading,
video,
grid,
background
]
};
10 changes: 10 additions & 0 deletions admin/app/fields/autoplay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { t } from '../i18n/translater.js';

export const autoplay = {
name: 'autoplay',
label: t.fields.autoplay,
widget: 'boolean',
default: false,
required: false,
i18n: 'duplicate'
};
10 changes: 10 additions & 0 deletions admin/app/fields/controls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { t } from '../i18n/translater.js';

export const controls = {
name: 'controls',
label: t.fields.controls,
widget: 'boolean',
default: true,
required: false,
i18n: 'duplicate'
};
11 changes: 11 additions & 0 deletions admin/app/fields/screenshot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { t } from '../i18n/translater.js';

export const screenshot = {
name: 'screenshot',
label: t.fields.screenshot.label,
hint: t.fields.screenshot.hint,
widget: 'boolean',
default: false,
required: false,
i18n: 'duplicate'
};
9 changes: 9 additions & 0 deletions admin/app/fields/transcription.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { t } from '../i18n/translater.js';

export const transcription = {
name: 'transcription',
label: t.fields.transcription,
widget: 'text',
required: false,
i18n: true
};
23 changes: 23 additions & 0 deletions admin/app/fields/video-mp4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { mediaLibrary } from '../settings/media-library.js';
import { t } from '../i18n/translater.js';
let maxFileSize = 10000000;
if (mediaLibrary) {
maxFileSize = 50000000;
}

export const mp4 = {
name: 'mp4',
label: t.fields.video.mp4.label,
widget: 'file',
required: false,
i18n: 'duplicate',
choose_url: false,
media_library: {
config: {
max_file_size: maxFileSize
}
},
hint: t.fields.video.mp4.hint,
media_folder: '/static/videos',
public_folder: '/videos'
};
23 changes: 23 additions & 0 deletions admin/app/fields/video-webm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { mediaLibrary } from '../settings/media-library.js';
import { t } from '../i18n/translater.js';
let maxFileSize = 10000000;
if (mediaLibrary) {
maxFileSize = 50000000;
}

export const webm = {
name: 'webm',
label: t.fields.video.webm.label,
widget: 'file',
required: false,
i18n: 'duplicate',
choose_url: false,
media_library: {
config: {
max_file_size: maxFileSize
}
},
hint: t.fields.video.webm.hint,
media_folder: '/static/videos',
public_folder: '/videos'
};
26 changes: 26 additions & 0 deletions admin/app/fields/video.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { autoplay } from './autoplay.js';
import { controls } from './controls.js';
import { legend } from './legend.js';
import { mp4 } from './video-mp4.js';
import { screenshot } from './screenshot.js';
import { t } from '../i18n/translater.js';
import { transcription } from './transcription.js';
import { webm } from './video-webm.js';

export const video = {
name: 'video',
label: t.fields.video.label,
widget: 'object',
required: false,
i18n: true,
collapsed: true,
fields: [
mp4,
webm,
controls,
autoplay,
screenshot,
legend,
transcription
]
};
3 changes: 2 additions & 1 deletion admin/app/i18n/en/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,6 @@ export const blocks = {
}
}
},
title: 'Title'
title: 'Title',
video: 'Video'
};
19 changes: 19 additions & 0 deletions admin/app/i18n/en/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const fields = {
label: 'Authors?',
hint: 'Many authors possible'
},
autoplay: 'Autoplay?',
background: 'Add background color?',
background_color: 'Background color',
blank: 'Open in new page?',
Expand Down Expand Up @@ -96,6 +97,7 @@ export const fields = {
color: 'Color',
column: 'Number of columns',
contact: 'Contact',
controls: 'Control buttons?',
count: 'Number of elements',
credit: 'Credit',
cta: 'Button',
Expand Down Expand Up @@ -290,6 +292,10 @@ export const fields = {
show_gauge: 'Display a progress gauge?',
show_more: 'Display a button to discover more elements?',
sold: 'Sold?',
screenshot: {
label: 'Screenshot?',
hint: 'This will add a browser skin'
},
state: {
label: 'State',
options: {
Expand All @@ -314,13 +320,26 @@ export const fields = {
text_area: 'Text',
text_markdown: 'Text',
title: 'Title / Name',
transcription: 'Transcription',
twitter: {
label: 'Twitter',
hint: 'Username'
},
url: 'URL',
value: 'Value',
value_number: 'Value',
video: {
label: 'Video',
mp4: {
label: 'MP4',
hint: 'Video in MP4 format'
},
poster: 'Image from video',
webm: {
label: 'WEBM',
hint: 'Video in WEBM format'
}
},
website: {
label: 'Website',
hint: 'URL (https://…)'
Expand Down
3 changes: 2 additions & 1 deletion admin/app/i18n/fr/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,6 @@ export const blocks = {
}
}
},
title: 'Titre'
title: 'Titre',
video: 'Vidéo'
};
19 changes: 19 additions & 0 deletions admin/app/i18n/fr/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const fields = {
label: 'Auteurs ?',
hint: 'Plusieurs auteurs possible'
},
autoplay: 'Lecture automatique ?',
background: 'Ajouter une couleur d’arrière plan ?',
background_color: 'Couleur du fond',
blank: 'Ouvrir le lien dans une nouvelle fenêtre ?',
Expand Down Expand Up @@ -96,6 +97,7 @@ export const fields = {
color: 'Couleur',
column: 'Nombre de colonnes',
contact: 'Contact',
controls: 'Boutons de controle ?',
count: 'Nombre d’éléments',
credit: 'Crédit',
cta: 'Bouton',
Expand Down Expand Up @@ -289,6 +291,10 @@ export const fields = {
show_gauge: 'Afficher une jaune de progression ?',
show_more: 'Afficher un bouton pour découvrir plus d’éléments ?',
sold: 'Vendu ?',
screenshot: {
label: 'Capture d’écran ?',
hint: 'Ceci ajoutera un habillage navigateur'
},
state: {
label: 'État',
options: {
Expand All @@ -313,13 +319,26 @@ export const fields = {
text_area: 'Texte',
text_markdown: 'Texte',
title: 'Titre / Nom',
transcription: 'Transcription',
twitter: {
label: 'Twitter',
hint: "Nom d'utilisateur"
},
url: 'URL',
value: 'Valeur',
value_number: 'Valeur',
video: {
label: 'Vidéo',
mp4: {
label: 'MP4',
hint: 'Vidéo au format MP4'
},
poster: 'Image de la vidéo',
webm: {
label: 'WEBM',
hint: 'Vidéo au format WEBM'
}
},
website: {
label: 'Site web',
hint: 'URL (https://…)'
Expand Down
1 change: 1 addition & 0 deletions admin/app/settings/available-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ export { block_selectedprojects } from '../blocks/selected-projects.js';
// export { block_selectedservices } from "../blocks/selected-services.js"
export { block_testimonials } from '../blocks/testimonials.js';
export { block_title } from '../blocks/title.js';
export { block_video } from '../blocks/video.js';

0 comments on commit 7350a74

Please sign in to comment.