Skip to content

Conversation

@feihaozi77
Copy link

Added all components for inlineBorderRadiusEditor

@flukeout
Copy link

flukeout commented Nov 3, 2017

Hey, awesome - this is super cool @feihaozi77 👍 Some thoughts...

  • When moving the slider, is it possible to change the value when the slider is moving and not just when the slider stops moving?
    • I think the oninput event should do the trick
    • onchange only fires at the end
  • Let's not have any decimal spots in the pixel values
    • Instead of 12.75px let's just use 13px
    • We can set a number of fixed steps for the input range element
  • After closing the border radius UI, is it possible to clear the selection, currently it ends up like this...

image

So when you type anything, it replaces the selection immediately.

Anyway, this is great - really excited to see this progress 💯

Of course, I'll take care of all the styling and UI once the functionality is getting closer to our final version.

@feihaozi77
Copy link
Author

@flukeout Sure I'll work on the parts you mentioned.

@feihaozi77
Copy link
Author

@flukeout made some changes

@flukeout
Copy link

Thanks for your patience @feihaozi77 - reviewing again now.

@flukeout
Copy link

This is getting really good! Here is some more feedback...

  • When adjusting the top-left-corner, is it possible to not also change the all-corners value?

border-radius

  • Is it possible to retain the values of the individual corners so they don't reset when you switch to the All corners mode?

corners-reset

I'm imagining a way where the individual and all modes have their own separate "memory". So if you make changes in one, it doesn't affect the other. So, let's say..

  • I make some changes to individual corners
  • I switch to all corners mode
  • The individual corner value sliders are not affected
  • If i switch back to individual corners mode, we apply those stored values to the CSS

Does it make sense? Let me know! Thanks so far!!

@feihaozi77
Copy link
Author

@flukeout I made the changes you need to seperate the allCornerSlider and the individualSlider, please review when you are avaliable

@flukeout
Copy link

Awesome, will try it out now.

@flukeout
Copy link

OK, great! I think that works much better. Some more requests:

Request 1
Is it possible to show the purple editor icon when there isn't a value yet for the CSS rule? I'm thinking of the case when the user has typed..

border-radius: but hasn't started to add any values yet.

I think it would be good to show the icon right then so they could start using the UI right away if they wanted to.

Request 2
Is it possible to show the pixel value after the range slider? Like this...

all corners ==0========== 12px

Once we get these changes in I can make a PR against your branch with styling updates, etc.

👍

@feihaozi77
Copy link
Author

@flukeout let me clarify request1, do you mean you want the purple icon to pop up automatically without user clicking the text when user finished typing something like border-radius:

@feihaozi77
Copy link
Author

@flukeout I think I'll get your request 2 done by tomorrow but the 1st request seems pretty hard, I've been stucking there for awhile, I looked into the PopoverWidget.js file, the positionPopover function is being called, if I set a break point inside the positionPopover function, the bubble was showed at first when the execution was stopping at the break point, but once I step over the break point the bubble just dispeared. I could not figure out this, maybe some one who are more familliar with codemirror could help

@flukeout
Copy link

Hey @feihaozi77 - yeah with regard to Request 1 - that's what I had in mind. If it's proving too time consuming, let's not worry about it too much at this point. We could always try to solve it with another effort down the road.

@feihaozi77
Copy link
Author

@flukeout request2 completed

@flukeout
Copy link

Awesome @feihaozi77 - will take a look a little later today!

@flukeout
Copy link

Looking now.

@flukeout
Copy link

This is great @feihaozi77! I've got a question: is it possible for the UI to be aware of the units used in the rule? For example, if I have border-radius: 5px 10%; and open the UI, it converts all of the units to px. Is it possible to keep %?

Then, on top of that, maybe we should add a toggle to each value that lets the user choose then unit. Something like this...

top-left-corner ===0======= 10 [px / % / em]

Let me know if that is possible. Thanks!

@feihaozi77
Copy link
Author

@flukeout regarding your request "if I have border-radius: 5px 10%; and open the UI, it converts all of the units to px. Is it possible to keep %?", should be able to do that. not sure about the toggle part yet.

@feihaozi77
Copy link
Author

@flukeout Added the part for keeping %, em and px units

@flukeout
Copy link

Testing now @feihaozi77 - thanks!

@flukeout
Copy link

Hey @feihaozi77, when opening a single-value border-radius, is it possible to also populate that value into all of the corner values? See the screencap below, when I open it, all of the values are set to 0...

image

@feihaozi77
Copy link
Author

@flukeout sure, I will work on that, and right now i'm trying to add the radio buttons for each of the corners to toggle their units

@flukeout flukeout closed this Nov 22, 2017
@flukeout flukeout reopened this Nov 22, 2017
@flukeout
Copy link

Ooops, sorry accidentally closed and opened. Awesome, thanks for the update, looking forward to it!

@feihaozi77
Copy link
Author

@humphd ready for review again

humphd
humphd previously requested changes Dec 18, 2017
src/brackets.js Outdated
require("utils/Resizer");
require("LiveDevelopment/main");
require("utils/ColorUtils");
require("utils/BorderRadiusUtils");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to require() a file needed by an extension in the core. Can you not move this into your main.js or the extension?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@humphd Should I remove this line from the brackets.js file?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think so. The only reason to have it here is if you have to have it loaded early for some reason so that other code can access it, and it has to do some kind of initialization. In your case, you should just load it when you need it, where you need it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the brackets.js, the colorUtil.js file is also being requried(), That's why I put the borderRadiusUtil.js in here. And I noticed that, if I remove the borderRadiusUtil.js file away from bracket.js, then the BorderRadiusUtil.js will not be loaded in the browser. So basically, if I remove the file from brackets.js, then in my extension, for instance, the InlineBorderRadius.js will not get the BorderRadiusUtils.js because it is using something like this " brackets.getModule("utils/BorderRadiusUtils"); " to load the util files.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both require() and brackets.getModule() do the same thing, namely, they load a module. However, you use one or the other depending on where the module is defined. For example, in the core of Brackets, you always use require(). In an extension, you use require() when the module you are loading is defined within the extension. However, if you need to load a core module in an extension, you use brackets.getModule().

If you only need this file in your extension code, which you do, you can just use require() in the extension code before it is used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it thank you, so I think instead of using brackets.getModule, I should use require() to do the samething in my extension files, because I'm only getting reference to that one file , it's not nessasary to put the file in the core module. is this correct?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You got it. Let me know if you need help getting it to load properly--sometimes there can be dependency load-order issues with require.

/** Mustache template that forms the bare DOM structure of the UI */
var BorderRadiusTemplate = require("text!BorderRadiusEditorTemplate.html");
var DEFAULT_BORDER_RADIUS_VALUE = 0;
/**
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't seem to match what's happening in the function

* @param {!{horizontalOffset: string, verticalOffset: string, blurRadius: string, spreadRadius: string, color: string}} values Initial set of box-shadow values.
* @param {!function(string)} callback Called whenever values change
*/
function replaceAll(value,str1,str2,ignore){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel like this is named well. You have a much more complex regex in here than just replacing one string in another. Can you add a comment to explain the regex, and what it's looking for, and also what this really does?

}

/**
* A string or tinycolor object representing the currently selected color
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still hasn't been addressed.


BorderRadiusEditor.prototype._setInputValues = function(setFromString) {
var values = this.individualValuesWithUnit;
if(!this._allCorners){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is all indented too far.


};
BorderRadiusEditor.prototype.setRadioButtons = function(values){
//when initializing
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indented too far.

BorderRadiusEditor.prototype.updateRadios=function(corner,unit){
if(corner==="tl"){
if(unit==="percent"){

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line

result+=_array[i];
}
this._values = result;
this._callback(value);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean you'll call the callback more than once, since _commitChanges is called more than once above? If so, is that expected? It's an odd pattern: usually you'd just call a callback once, and if you need to call it many times, you'd do some kind of event handler instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@humphd In this case, the event handler is being implemented in the InlineBorderRadiusEditor.js layer, whenever the UI element(slider) changes, it will trigger the event handler in BorderRadiusEditor.js, then BorderRadiusEditor.js will update the UI and then send control back to InlineBoderRadiusEditor.js by calling the _callback(), which is mapping to the _handleBorderRadiusChange() in the InlineBorderRadius.js. the _handleBorderRadiusChange() will be updating document text.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@humphd basically, in my code, the InlineBorderRadiusEditor.js handles the Document updating tasks while BorderRadiusEditor.js handles UI Updating first then send control to InlineBorderRadiusEditor.js to update the Text in the hostEditor.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@humphd I'm not really sure how to implement the event handler for the _callback, since BorderRadiusEditor and InlineBorderRadiusEditor works on different layers, could you give more hint on this? or maybe we can discuss about this in class tomorrow.

<header>
<ul class="button-bar">
<li id="allCorners" title="All Corners">
<a href="#" tabindex="0">All Corners</a>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to localize all user visible strings.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flukeout @humphd I noticed there are so many files in the src/nls folder for storing all localized strings. Since I need localize all those user visible strings, can anyone tell me where I should save those string key value pairs to?

@@ -0,0 +1,412 @@
@sansFontFamily: "Open Sans" , Helvetica, Arial, sans-serif;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to confirm with @flukeout the font choice here so it matches what we use elsewhere.

@humphd
Copy link

humphd commented Dec 19, 2017

src/brackets.js Outdated
require("utils/Resizer");
require("LiveDevelopment/main");
require("utils/ColorUtils");
//require("utils/BorderRadiusUtils");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

return parsedResult;
}

function BorderRadiusEditor($parent, values, callback) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename callback to indicate that it's a handler

@humphd humphd requested a review from gideonthomas December 19, 2017 16:51
@feihaozi77
Copy link
Author

feihaozi77 commented Dec 19, 2017

@humphd @gideonthomas I made a Pull Request to the thimble repo for adding the localized strings to the locales folder in thimble repe. Please take a look and let me know if that's OK. Here is the PR link mozilla/thimble.mozilla.org#2585

@feihaozi77
Copy link
Author

@humphd @gideonthomas ready for review!

@gideonthomas
Copy link

@feihaozi77, sorry about the delayed response...I haven't forgotten about your PR. Since this is a pretty big code change, I'm going to open a PR against your branch that you can merge in with changes that I suggest.

Copy link

@gideonthomas gideonthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @feihaozi77, I have opened up a PR against your branch as you can see in feihaozi77#3. Please read the comment there.

@feihaozi77
Copy link
Author

@gideonthomas I have merged your branch. Good work!! I like the idea that you implement the BorderRadiusValue class which makes the code much cleaner and reusable. Thank you very much!!

Copy link

@gideonthomas gideonthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a few more comments @feihaozi77


this.allCorners = values.length === 1;

if (!this.allCorners) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed another bug. Change this entire if into:

if (!this.allCorners) {
  secondValue = values[1];

  if (numOfValues === 2) {
    fourthValue = secondValue;
  } else {
    thirdValue = values[2];

    if (numOfValues === 3) {
      fourthValue = secondValue;
    } else {
      fourthValue = values[3];
    }
  }
}

secondValue.unit,
this.onChange
);
this.bottomLeft = new BorderRadiusValue(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be this.bottomRight

);
this.bottomLeft = new BorderRadiusValue(
this.$element,
"bottom-left",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be "bottom-right"

thirdValue.unit,
this.onChange
);
this.bottomRight = new BorderRadiusValue(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be this.bottomLeft

);
this.bottomRight = new BorderRadiusValue(
this.$element,
"bottom-right",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to bottom-left

/** @type {boolean} True while we're syncing a color picker change into the code editor */
InlineBorderRadiusEditor.prototype._isOwnChange = null;

/** @type {boolean} True while we're syncing a code editor change into the color picker */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update this comment



/**
* Returns the current text range of the color we're attached to, or null if

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update this comment

}
}

function queryInlineBorderRadiusEditorPrivoder(hostEditor, pos) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo


// Initialize extension
ExtensionUtils.loadStyleSheet(module, "css/main.less");
EditorManager.registerInlineEditProvider(inlineBorderRadiusEditorProvider, queryInlineBorderRadiusEditorPrivoder);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

return true;
}

// Get the css property name after removing spaces and ":" so that we can check for it in the file ColorProperties.json

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update this comment

@feihaozi77
Copy link
Author

@gideonthomas changes are made!

Copy link

@gideonthomas gideonthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs one more indentation change, otherwise this is good to go.

secondValue = values[1];

if (numOfValues === 2) {
fourthValue = secondValue;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix the indentation here. Needs to be 4 spaces.

@gideonthomas
Copy link

Thanks for making the changes @feihaozi77, this looks good now!

@gideonthomas gideonthomas merged commit 127fc17 into mozilla:master Jan 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants