-
-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: language selection into context menu
- Loading branch information
1 parent
bf3023a
commit ce7e3c5
Showing
28 changed files
with
277 additions
and
301 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
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
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
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
61 changes: 61 additions & 0 deletions
61
packages/mythic-notebook/src/language-info/components/language-selector.tsx
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,61 @@ | ||
import { EditableText } from "@blueprintjs/core"; | ||
import { MythicComponent } from "@nteract/myths"; | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import { CellAddress } from "../../types"; | ||
import { setCellLanguageFromName } from "../myths/set-cell-language-from-name"; | ||
import { languageOfCellOnly } from "../selectors"; | ||
|
||
const LeftRightLayout = | ||
styled.div` | ||
display: flex; | ||
flex-grow: 1; | ||
& > *:nth-child(1) { | ||
flex-grow: 1; | ||
} | ||
& > *:nth-child(2) { | ||
& > * { | ||
text-align: right; | ||
} | ||
& > input { | ||
color: black; | ||
background: white; | ||
opacity: 50%; | ||
} | ||
} | ||
`; | ||
|
||
export const LanguageSelector = | ||
setCellLanguageFromName.createConnectedComponent( | ||
"LanguageSelector", | ||
class extends MythicComponent< | ||
typeof setCellLanguageFromName, | ||
{cellAddress: CellAddress, language?: string} | ||
> { | ||
render(): JSX.Element { | ||
const onTextChange = (text: string) => | ||
this.props.setCellLanguageFromName({ref: this.props.cellAddress, langName: text}); | ||
|
||
return ( | ||
<LeftRightLayout className="set-cell-language"> | ||
<output>{this.props.language}</output> | ||
<EditableText | ||
selectAllOnFocus={true} | ||
placeholder="Set cell language..." | ||
onChange={onTextChange} | ||
/> | ||
</LeftRightLayout> | ||
); | ||
} | ||
|
||
onTextChange(text: string) { | ||
this.props.setCellLanguageFromName({ref: this.props.cellAddress, langName: text}); | ||
} | ||
}, | ||
(state, { cellAddress }) => ({ | ||
language: languageOfCellOnly(state, cellAddress), | ||
}), | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export { languageInfo } from "./package"; | ||
export * from "./types"; | ||
export * from "./selectors"; | ||
export * from "./myths/set-language"; | ||
export * from "./myths/set-content-language-from-info"; | ||
export * from "./myths/set-cell-language-from-name"; | ||
export * from "./components/language-selector"; |
Oops, something went wrong.