-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): ProjectCreate path preview
- Loading branch information
Guillaume Chau
committed
Mar 6, 2018
1 parent
db67f1e
commit d0703b0
Showing
3 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Display a folder path | ||
* @param {string} value path | ||
* @param {number} maxLength maximum length of displayed path | ||
*/ | ||
export function folder (value, maxLength = -1) { | ||
value = value.replace(/\\/g, '/') | ||
|
||
if (value.charAt(value.length - 1) !== '/') { | ||
value += '/' | ||
} | ||
|
||
if (maxLength !== -1 && value.length > maxLength) { | ||
const exceeded = value.length - maxLength + 3 | ||
const firstEnd = Math.floor(maxLength / 2 - exceeded / 2) | ||
const lastStart = Math.ceil(maxLength / 2 + exceeded / 2) | ||
value = value.substring(0, firstEnd) + '...' + value.substring(lastStart) | ||
} | ||
|
||
return value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters