Skip to content

Commit

Permalink
[Proposition] Allow user to reset setting to default values (#630)
Browse files Browse the repository at this point in the history
* Allow user to reset setting to default values

* Move styling closer to fantomas-tab comment

* Move the Reset setting button up
  • Loading branch information
MangelMaxime authored Dec 18, 2023
1 parent 2c7d263 commit c9d69a9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/client/fsharp/FantomasOnline/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Msg =
| ChangeMode of FantomasMode
| CopySettings
| UpdateSettingsFilter of string
| ResetSettings

[<RequireQualifiedAccess>]
type FantomasTabState =
Expand Down
8 changes: 8 additions & 0 deletions src/client/fsharp/FantomasOnline/State.fs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ let update isActiveTab (bubble: BubbleModel) msg model =
UserOptions = userOptions
State = FantomasTabState.OptionsLoaded },
cmd

| ResetSettings ->
showSuccess "Settings reset to default values"

{ model with
UserOptions = optionsListToMap model.DefaultOptions },
Cmd.none

| Format ->
let cmd =
Cmd.batch
Expand Down
10 changes: 10 additions & 0 deletions src/client/fsharp/FantomasOnline/View.fs
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,21 @@ let settings isFsi model dispatch =
]
]

let resetSettings =
div [ ClassName Style.ResetSettings ] [
button [ ClassName Style.Secondary; OnClick(fun _ -> ResetSettings |> dispatch) ] [
str "Reset settings"
]
]

fragment [] [
VersionBar.versionBar (sprintf "Version: %s" model.Version)
fantomasMode
fileExtension
hr []
if userChangedSettings model then
resetSettings
hr []
searchBox
options
]
Expand Down
8 changes: 8 additions & 0 deletions src/client/src/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,14 @@ nav > div #docs-btn .long-text {
margin: 0;
}

.reset-settings {
display: flex;
}

.reset-settings > button {
margin: auto;
}

/* dark mode */
@media (prefers-color-scheme: dark) {
:root {
Expand Down

0 comments on commit c9d69a9

Please sign in to comment.