Skip to content

Commit

Permalink
3.0.0-beta.10 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Jun 15, 2018
1 parent e61fb6b commit 63ec1dd
Show file tree
Hide file tree
Showing 64 changed files with 2,854 additions and 656 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

# Change Log

# [v3.0.0-beta.10](https://github.com/framework7io/framework7/compare/v3.0.0-beta.9...v3.0.0-beta.10) - June 15, 2018
* Core
* All new Gauge component with responsive SVG gauges
* Router
* Added `preRoute` support (middleware) that can be configured per route or globally on View/Router init for all routes
* Smart Select
* New `change`/`smartSelectChange` events
* Autocomplete
* Fixed error with undefined value replacement
* Tooltip
* New `setText` method to dynamically change Tooltip's text/content
* Phenome
* Better validation logic for `Input` component
* `Toggle` - fixed issue when `toggleChange` event not being fired on desktop
* `ListItemContent` - fixed issue with calling `setState` in render function
* Support for `target` prop/attribute for `Link`, `Button`, `Fab`, `FabButton` components
* Tooltip support (with `tooltip` prop) for `Fab` and `FabButton` components
* New `Gauge` (React) / `f7-gauge` (Vue) component to produce responsive SVG gauges
* Added Smart Select for `Link` component with `smartSelect` and `smartSelectParams` props

# [v3.0.0-beta.9](https://github.com/framework7io/framework7/compare/v3.0.0-beta.8...v3.0.0-beta.9) - June 12, 2018
* Core
* All new Tooltip component
Expand Down
4 changes: 2 additions & 2 deletions packages/core/components/autocomplete/autocomplete-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class Autocomplete extends Framework7Class {
const ac = this;
if (ac.params.renderItem) return ac.params.renderItem.call(ac, item, index);
let itemHtml;
const itemValue = item.value.replace(/"/g, '"');
const itemValue = item.value ? item.value.replace(/"/g, '"') : item.value;
if (ac.params.openIn !== 'dropdown') {
itemHtml = `
<li>
Expand Down Expand Up @@ -580,7 +580,7 @@ class Autocomplete extends Framework7Class {
backdropEl: $el.find('.searchbar-backdrop'),
customSearch: true,
on: {
searchbarSearch(sb, query) {
search(sb, query) {
if (query.length === 0 && ac.searchbar.enabled) {
ac.searchbar.backdropShow();
} else {
Expand Down
6 changes: 6 additions & 0 deletions packages/core/components/button/button-ios.less
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
border-radius: 5px 0 0 5px;
border-left-width: 1px;
border-left-style: solid;
&.button-small {
border-left-width: 2px;
}
}
&:last-child {
border-radius: 0 5px 5px 0;
Expand All @@ -91,6 +94,9 @@
border-radius: 0 5px 5px 0;
border-right-width: 1px;
border-right-style: solid;
&.button-small {
border-right-width: 2px;
}
}
&:last-child {
border-radius: 5px 0 0 5px;
Expand Down
1 change: 1 addition & 0 deletions packages/core/components/button/button-md.less
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
}
.button {
border-radius: 0;
min-width: 0;
.ltr({
border-left: 1px solid rgba(0,0,0,0.1);
&:first-child {
Expand Down
307 changes: 307 additions & 0 deletions packages/core/components/gauge/gauge-class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
/* eslint no-nested-ternary: off */
import $ from 'dom7';
import Utils from '../../utils/utils';
import Framework7Class from '../../utils/class';

class Gauge extends Framework7Class {
constructor(app, params = {}) {
// Extends with open/close Modal methods;
super(app, params);

const gauge = this;

const defaults = Utils.extend({}, app.params.gauge);

// Extend defaults with modules params
gauge.useModulesParams(defaults);

gauge.params = Utils.extend(defaults, params);

const { el } = gauge.params;
if (!el) return gauge;

const $el = $(el);
if ($el.length === 0) return gauge;


Utils.extend(gauge, {
app,
$el,
el: $el && $el[0],
});

$el[0].f7Gauge = gauge;

// Install Modules
gauge.useModules();

gauge.init();

return gauge;
}
calcRadius() {
const gauge = this;
const { size, borderWidth } = gauge.params;
return (size / 2) - (borderWidth / 2);
}
calcBorderLength() {
const gauge = this;
const radius = gauge.calcRadius();
return 2 * Math.PI * radius;
}
render() {
const gauge = this;
if (gauge.params.render) return gauge.params.render.call(gauge, gauge);

const {
type,
value,
size,
bgColor,
borderBgColor,
borderColor,
borderWidth,
valueText,
valueTextColor,
valueFontSize,
valueFontWeight,
labelText,
labelTextColor,
labelFontSize,
labelFontWeight,
} = gauge.params;

const semiCircle = type === 'semicircle';
const radius = gauge.calcRadius();
const length = gauge.calcBorderLength();
const progress = Math.max(Math.min(value, 1), 0);

return `
<svg class="gauge-svg" width="${size}px" height="${semiCircle ? size / 2 : size}px" viewBox="0 0 ${size} ${semiCircle ? size / 2 : size}">
${semiCircle ? `
<path
class="gauge-back-semi"
d="M${size - (borderWidth / 2)},${size / 2} a1,1 0 0,0 -${size - borderWidth},0"
stroke="${borderBgColor}"
stroke-width="${borderWidth}"
fill="${bgColor || 'none'}"
/>
<path
class="gauge-front-semi"
d="M${size - (borderWidth / 2)},${size / 2} a1,1 0 0,0 -${size - borderWidth},0"
stroke="${borderColor}"
stroke-width="${borderWidth}"
stroke-dasharray="${length / 2}"
stroke-dashoffset="${(length / 2) * (progress - 1)}"
fill="${borderBgColor ? 'none' : (bgColor || 'none')}"
/>
` : `
${borderBgColor ? `
<circle
class="gauge-back-circle"
stroke="${borderBgColor}"
stroke-width="${borderWidth}"
fill="${bgColor || 'none'}"
cx="${size / 2}"
cy="${size / 2}"
r="${radius}"
></circle>
` : ''}
<circle
class="gauge-front-circle"
transform="${`rotate(-90 ${size / 2} ${size / 2})`}"
stroke="${borderColor}"
stroke-width="${borderWidth}"
stroke-dasharray="${length}"
stroke-dashoffset="${length * (1 - progress)}"
fill="${borderBgColor ? 'none' : bgColor || 'none'}"
cx="${size / 2}"
cy="${size / 2}"
r="${radius}"
></circle>
`}
${valueText ? `
<text
class="gauge-value-text"
x="50%"
y="${semiCircle ? '100%' : '50%'}"
font-weight="${valueFontWeight}"
font-size="${valueFontSize}"
fill="${valueTextColor}"
dy="${semiCircle ? (labelText ? -labelFontSize - 15 : -5) : 0}"
text-anchor="middle"
dominant-baseline="${!semiCircle && 'middle'}"
>${valueText}</text>
` : ''}
${labelText ? `
<text
class="gauge-label-text"
x="50%"
y="${semiCircle ? '100%' : '50%'}"
font-weight="${labelFontWeight}"
font-size="${labelFontSize}"
fill="${labelTextColor}"
dy="${semiCircle ? -5 : (valueText ? ((valueFontSize / 2) + 10) : 0)}"
text-anchor="middle"
dominant-baseline="${!semiCircle && 'middle'}"
>${labelText}</text>
` : ''}
</svg>
`.trim();
}
update(newParams = {}) {
const gauge = this;
const { params, $gaugeSvgEl } = gauge;

Object.keys(newParams).forEach((param) => {
if (typeof newParams[param] !== 'undefined') {
params[param] = newParams[param];
}
});
if ($gaugeSvgEl.length === 0) return gauge;

const {
value,
size,
bgColor,
borderBgColor,
borderColor,
borderWidth,
valueText,
valueTextColor,
valueFontSize,
valueFontWeight,
labelText,
labelTextColor,
labelFontSize,
labelFontWeight,
} = params;

const length = gauge.calcBorderLength();
const progress = Math.max(Math.min(value, 1), 0);
const radius = gauge.calcRadius();
const semiCircle = params.type === 'semicircle';

const svgAttrs = {
width: `${size}px`,
height: `${semiCircle ? size / 2 : size}px`,
viewBox: `0 0 ${size} ${semiCircle ? size / 2 : size}`,
};
Object.keys(svgAttrs).forEach((attr) => {
$gaugeSvgEl.attr(attr, svgAttrs[attr]);
});
if (semiCircle) {
const backAttrs = {
d: `M${size - (borderWidth / 2)},${size / 2} a1,1 0 0,0 -${size - borderWidth},0`,
stroke: borderBgColor,
'stroke-width': borderWidth,
fill: bgColor || 'none',
};
const frontAttrs = {
d: `M${size - (borderWidth / 2)},${size / 2} a1,1 0 0,0 -${size - borderWidth},0`,
stroke: borderColor,
'stroke-width': borderWidth,
'stroke-dasharray': length / 2,
'stroke-dashoffset': (length / 2) * (progress - 1),
fill: borderBgColor ? 'none' : (bgColor || 'none'),
};
Object.keys(backAttrs).forEach((attr) => {
$gaugeSvgEl.find('.gauge-back-semi').attr(attr, backAttrs[attr]);
});
Object.keys(frontAttrs).forEach((attr) => {
$gaugeSvgEl.find('.gauge-front-semi').attr(attr, frontAttrs[attr]);
});
} else {
const backAttrs = {
stroke: borderBgColor,
'stroke-width': borderWidth,
fill: bgColor || 'none',
cx: size / 2,
cy: size / 2,
r: radius,
};
const frontAttrs = {
transform: `rotate(-90 ${size / 2} ${size / 2})`,
stroke: borderColor,
'stroke-width': borderWidth,
'stroke-dasharray': length,
'stroke-dashoffset': length * (1 - progress),
fill: borderBgColor ? 'none' : bgColor || 'none',
cx: size / 2,
cy: size / 2,
r: radius,
};
Object.keys(backAttrs).forEach((attr) => {
$gaugeSvgEl.find('.gauge-back-circle').attr(attr, backAttrs[attr]);
});
Object.keys(frontAttrs).forEach((attr) => {
$gaugeSvgEl.find('.gauge-front-circle').attr(attr, frontAttrs[attr]);
});
}
if (valueText) {
if (!$gaugeSvgEl.find('.gauge-value-text').length) {
$gaugeSvgEl.append('<text class="gauge-value-text"></text>');
}
const textAttrs = {
x: '50%',
y: semiCircle ? '100%' : '50%',
'font-weight': valueFontWeight,
'font-size': valueFontSize,
fill: valueTextColor,
dy: semiCircle ? (labelText ? -labelFontSize - 15 : -5) : 0,
'text-anchor': 'middle',
'dominant-baseline': !semiCircle && 'middle',
};
Object.keys(textAttrs).forEach((attr) => {
$gaugeSvgEl.find('.gauge-value-text').attr(attr, textAttrs[attr]);
});
$gaugeSvgEl.find('.gauge-value-text').text(valueText);
} else {
$gaugeSvgEl.find('.gauge-value-text').remove();
}
if (labelText) {
if (!$gaugeSvgEl.find('.gauge-label-text').length) {
$gaugeSvgEl.append('<text class="gauge-label-text"></text>');
}
const labelAttrs = {
x: '50%',
y: semiCircle ? '100%' : '50%',
'font-weight': labelFontWeight,
'font-size': labelFontSize,
fill: labelTextColor,
dy: semiCircle ? -5 : (valueText ? ((valueFontSize / 2) + 10) : 0),
'text-anchor': 'middle',
'dominant-baseline': !semiCircle && 'middle',
};
Object.keys(labelAttrs).forEach((attr) => {
$gaugeSvgEl.find('.gauge-label-text').attr(attr, labelAttrs[attr]);
});
$gaugeSvgEl.find('.gauge-label-text').text(labelText);
} else {
$gaugeSvgEl.find('.gauge-label-text').remove();
}
return gauge;
}
init() {
const gauge = this;
const $gaugeSvgEl = $(gauge.render()).eq(0);
$gaugeSvgEl.f7Gauge = gauge;
Utils.extend(gauge, {
$gaugeSvgEl,
gaugeSvgEl: $gaugeSvgEl && $gaugeSvgEl[0],
});
gauge.$el.append($gaugeSvgEl);
return gauge;
}
destroy() {
const gauge = this;
if (!gauge.$el || gauge.destroyed) return;
gauge.$el.trigger('gauge:beforedestroy', gauge);
gauge.emit('local::beforeDestroy gaugeBeforeDestroy', gauge);
gauge.$gaugeSvgEl.remove();
delete gauge.$el[0].f7Gauge;
Utils.deleteProps(gauge);
gauge.destroyed = true;
}
}
export default Gauge;
3 changes: 3 additions & 0 deletions packages/core/components/gauge/gauge-ios.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.ios {
@import (multiple) '../../less/colors-ios.less';
}
3 changes: 3 additions & 0 deletions packages/core/components/gauge/gauge-md.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.md {
@import (multiple) '../../less/colors-md.less';
}
Loading

0 comments on commit 63ec1dd

Please sign in to comment.