Skip to content

Commit

Permalink
add "powered by" footer and credits prop
Browse files Browse the repository at this point in the history
  • Loading branch information
rikschennink committed Nov 2, 2020
1 parent 91adef8 commit ff62702
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 4.23.0

- Add "powered by" footer and [credits prop](https://pqina.nl/filepond/docs/patterns/api/filepond-instance/#disabling-credits).


## 4.22.1

- Fix problem with locale files.
Expand Down
20 changes: 19 additions & 1 deletion dist/filepond.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePond 4.22.1
* FilePond 4.23.0
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down Expand Up @@ -925,3 +925,21 @@
margin-top: 1em;
margin-bottom: 1em;
}

.filepond--root .filepond--credits {
position: absolute;
right: 0;
opacity: 0.175;
line-height: 0.85;
font-size: 11px;
color: inherit;
text-decoration: none;
z-index: 3;
bottom: -14px;
}

.filepond--root .filepond--credits[style] {
top: 0;
bottom: auto;
margin-top: 14px;
}
30 changes: 27 additions & 3 deletions dist/filepond.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePond 4.22.1
* FilePond 4.23.0
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down Expand Up @@ -2023,7 +2023,10 @@ const defaultOptions = {
styleButtonRemoveItemAlign: [false, Type.BOOLEAN],

// custom initial files array
files: [[], Type.ARRAY]
files: [[], Type.ARRAY],

// show support by displaying credits
credits: [['https://pqina.nl/', 'Powered by PQINA'], Type.ARRAY]
};

const getItemByQuery = (items, query) => {
Expand Down Expand Up @@ -6044,11 +6047,12 @@ const write$3 = ({ root, props }) => {

const panel = createView({
name: 'panel',
read: ({ root, props }) => (props.heightCurrent = root.ref.bottom.translateY),
write: write$3,
create: create$6,
ignoreRect: true,
mixins: {
apis: ['height', 'scalable']
apis: ['height', 'heightCurrent', 'scalable']
}
});

Expand Down Expand Up @@ -8171,6 +8175,22 @@ const create$e = ({ root, props }) => {
root.element.addEventListener('touchmove', prevent, { passive: false });
root.element.addEventListener('gesturestart', prevent);
}

// add credits
const credits = root.query('GET_CREDITS');
const hasCredits = credits.length === 2;
if (hasCredits) {
const frag = document.createElement('a');
frag.className = 'filepond--credits';
frag.setAttribute('aria-hidden', 'true');
frag.href = credits[0];
frag.tabindex = -1;
frag.target = '_blank';
frag.rel = 'noopener noreferrer';
frag.textContent = credits[1];
root.element.appendChild(frag);
root.ref.credits = frag;
}
};

const write$9 = ({ root, props, actions }) => {
Expand Down Expand Up @@ -8398,6 +8418,10 @@ const write$9 = ({ root, props, actions }) => {
// set container bounds (so pushes siblings downwards)
root.height = Math.max(labelHeight, boundsHeight - itemMargin);
}

// move credits to bottom
if (root.ref.credits && panel.heightCurrent)
root.ref.credits.style.transform = `translateY(${panel.heightCurrent}px)`;
};

const calculateListItemMargin = root => {
Expand Down
4 changes: 2 additions & 2 deletions dist/filepond.esm.min.js

Large diffs are not rendered by default.

35 changes: 32 additions & 3 deletions dist/filepond.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePond 4.22.1
* FilePond 4.23.0
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down Expand Up @@ -4063,7 +4063,10 @@
styleButtonRemoveItemAlign: [false, Type.BOOLEAN],

// custom initial files array
files: [[], Type.ARRAY]
files: [[], Type.ARRAY],

// show support by displaying credits
credits: [['https://pqina.nl/', 'Powered by PQINA'], Type.ARRAY]
};

var getItemByQuery = function getItemByQuery(items, query) {
Expand Down Expand Up @@ -8731,11 +8734,16 @@

var panel = createView({
name: 'panel',
read: function read(_ref3) {
var root = _ref3.root,
props = _ref3.props;
return (props.heightCurrent = root.ref.bottom.translateY);
},
write: write$3,
create: create$6,
ignoreRect: true,
mixins: {
apis: ['height', 'scalable']
apis: ['height', 'heightCurrent', 'scalable']
}
});

Expand Down Expand Up @@ -11090,6 +11098,22 @@
root.element.addEventListener('touchmove', prevent, { passive: false });
root.element.addEventListener('gesturestart', prevent);
}

// add credits
var credits = root.query('GET_CREDITS');
var hasCredits = credits.length === 2;
if (hasCredits) {
var frag = document.createElement('a');
frag.className = 'filepond--credits';
frag.setAttribute('aria-hidden', 'true');
frag.href = credits[0];
frag.tabindex = -1;
frag.target = '_blank';
frag.rel = 'noopener noreferrer';
frag.textContent = credits[1];
root.element.appendChild(frag);
root.ref.credits = frag;
}
};

var write$9 = function write(_ref3) {
Expand Down Expand Up @@ -11333,6 +11357,11 @@
// set container bounds (so pushes siblings downwards)
root.height = Math.max(labelHeight, boundsHeight - itemMargin);
}

// move credits to bottom
if (root.ref.credits && panel.heightCurrent)
root.ref.credits.style.transform =
'translateY(' + panel.heightCurrent + 'px)';
};

var calculateListItemMargin = function calculateListItemMargin(root) {
Expand Down
4 changes: 2 additions & 2 deletions dist/filepond.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/filepond.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filepond",
"version": "4.22.1",
"version": "4.23.0",
"description": "FilePond, Where files go to stretch their bits.",
"license": "MIT",
"author": {
Expand Down
22 changes: 20 additions & 2 deletions src/css/root.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,26 @@
}

.filepond--list-scroller {
margin-top:1em;
margin-bottom:1em;
margin-top: 1em;
margin-bottom: 1em;
}

.filepond--credits {
position: absolute;
right: 0;
opacity: 0.175;
line-height: .85;
font-size: 11px;
color: inherit;
text-decoration: none;
z-index: 3;
bottom: -14px;
}

.filepond--credits[style] {
top: 0;
bottom: auto;
margin-top: 14px;
}

}
5 changes: 4 additions & 1 deletion src/js/app/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,8 @@ export const defaultOptions = {
styleButtonRemoveItemAlign: [false, Type.BOOLEAN],

// custom initial files array
files: [[], Type.ARRAY]
files: [[], Type.ARRAY],

// show support by displaying credits
credits: [['https://pqina.nl/', 'Powered by PQINA'], Type.ARRAY]
};
3 changes: 2 additions & 1 deletion src/js/app/view/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ const write = ({ root, props }) => {

export const panel = createView({
name: 'panel',
read: ({ root, props }) => props.heightCurrent = root.ref.bottom.translateY,
write,
create,
ignoreRect: true,
mixins: {
apis: ['height', 'scalable']
apis: ['height', 'heightCurrent', 'scalable']
}
});
19 changes: 19 additions & 0 deletions src/js/app/view/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ const create = ({ root, props }) => {
root.element.addEventListener('touchmove', prevent, { passive: false });
root.element.addEventListener('gesturestart', prevent);
}

// add credits
const credits = root.query('GET_CREDITS');
const hasCredits = credits.length === 2;
if (hasCredits) {
const frag = document.createElement('a');
frag.className = 'filepond--credits';
frag.setAttribute('aria-hidden', 'true');
frag.href = credits[0];
frag.tabindex = -1;
frag.target = '_blank';
frag.rel = 'noopener noreferrer';
frag.textContent = credits[1];
root.element.appendChild(frag);
root.ref.credits = frag;
}
};

const write = ({ root, props, actions }) => {
Expand Down Expand Up @@ -324,6 +340,9 @@ const write = ({ root, props, actions }) => {
// set container bounds (so pushes siblings downwards)
root.height = Math.max(labelHeight, boundsHeight - itemMargin);
}

// move credits to bottom
if (root.ref.credits && panel.heightCurrent) root.ref.credits.style.transform = `translateY(${panel.heightCurrent}px)`;
};

const calculateListItemMargin = (root) => {
Expand Down

0 comments on commit ff62702

Please sign in to comment.